Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prevent Running Whole Script

Status
Not open for further replies.

barryp

Programmer
Jan 30, 2002
48
0
0
GB
Hi

We use SAS v8 for windows & an all-to-frequent mistake is to forget to highlight the PROC or DATA step to run. This results (of course) in the WHOLE script (all DATA & PROC steps) being run - disaster !

Being new to the company (& SAS) I thought that just adding a line "SAS - STOP HERE" as the first line in each script would be enough.
But, of course the stop/exit/.. must be in a DATA/PROC step. Then it just stops that step AND carries on with the next . .

Any ideas out there ???
 
BarryP,
I never thought about this 'problem' as most IDE's have this method. You must highlight what you want to execute or by default SAS will run all the way through. What you can do, and I think this is cloogy - though I do this often, is comment out the rest of the program using the '/**/' comments. The problem with this method is twofold you must remember to uncomment the rest of the code. You also have to make sure that there are no other hard comments in the rest of the code block or the comment will not extend as far as you would like. The SAS enhanced editor should show you the commented text in a green color (default).

Another method you may want to try is to have your code executed in 'chunks'. These are miniprograms that could be written in macros. When you want to run a particular 'macro', use another editor window and run just that macro.

I must say that this is the first time I've ever heard a complaint with this feature. It should be the programmer's job to run only what they want to run. Yes mistakes are made, but thats what they are mistakes. Is it so bad that the whole program runs once or twice? If its a long program you could use the ctrl+Break keys and stop the rest of the SAS job.

Hope that this helps.
Klaz2002
 
Barryp,
klaz2002 has good suggestions.. couple more are
if you are running in batch mode,
using Endsas; statement executes your logic only upto that point.

if you do not want to execute the code which is in the middle of your program then create that portion into a dummy macro and not executing the macro would just comment out that much of code. This mathod is good when you have a large amount of code that you want to omit, but also has comments within..

hth.




 
Thanks to you both for replying. Good ideas have been logged !

For, I guess, historic reasons the company has many scripts, each dedicated to particular 'jobs' & datasets.
When its time for a job to be run 'we' load the script into the editor, highlight the 'include' section (several lines of includes) & execute that, page down to the relevant section of code, highlight that & run it. Then - usually several days later - when it has completed we inspect the log & highlight the next section & execute that.

I just thought that a powerful statement like 'Stop Executing All procs' as the first line of the script would help prevent disasters. The only ones I've found actually close down SAS completely, losing the Logs etc...

Thanks again for your helpful contributions to an old PHP/C programmer learning SAS.
 
barryp,

From you statement that you lose the log sometimes (when the SAS session shutsdown) tells me that you are not redirecting the log. You should use PROC PRINTTO to redirect the log to a file. See the SAS documentation on that proc for the optins that go along with it. This way you could utilize the methods that shut down the sessions. You still have your log files stored in a file.
Klaz2002
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top