Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quit vs Run statements in SAS

Tags:

sas

In SAS, what is the difference between 'quit' and 'run'? statements? I cannot figure out when to use 'quit' and when to use 'run'? For example, why is proc datasets using quit but proc contents using run

like image 627
Victor Avatar asked Nov 17 '15 18:11

Victor


People also ask

What does run Statement do in SAS?

Although the RUN statement is not required between steps in a SAS program, using it creates a step boundary and can make the SAS log easier to read.

Why is QUIT used in PROC SQL?

The QUIT statement is used for RUN-group processing that enables you to submit certain procedures with a RUN statement, but the RUN statement will not end the procedure. This allows you to continue to use the same procedure without submitting another procedure.

Is run statement necessary in SAS?

The RUN statement is not required between steps in a SAS program. However, it is a best practice to use a RUN statement because it can make the SAS program easier to read and the SAS log easier to understand when debugging.

What is a run statement?

A run statement refers to a statement supplied by the purchaser of oil or gas to an interest owner that set forth the gross volume of product taken, sales value, taxes paid, and net payment to the owner. It is used to read a Natural source program from the Natural system file and then execute it.


1 Answers

This dates back to where SAS used to be a mainframe program (and still can be!).

RUN; is a command for SAS to run the submitted statements. Back in the older mainframe days, statements would've been submitted to SAS one at a time (or in batches, but the core concept here is that each line is separate from SAS's point of view). SAS accepts statements without doing anything until it hits a RUN; or something else that would create a step boundary (another DATA or PROC line, usually). In a data step, or a non-interactive proc (proc means, for example - a proc that can only do one set of instructions, and then exits), run tells it to do (whatever) and then return to a blank slate.

QUIT; is used in interactive programming environments. IML, SQL, many of the regression and modelling PROCs, FORMAT, TEMPLATE, DATASETS, etc. - all can be used interactively, meaning, more than one set of instructions can be sent to them.

In these interactive cases, you want SAS to go ahead and run some of the instructions, but still keep that PROC's environment open - your next statement would be in the same PROC, for example. Some of those run immediately - PROC SQL is a good example of this - while some (particularly the modelling PROCs) RUN; does something (tells it to run the model so far) but it won't exit the proc until QUIT; is encountered (or another step boundary that requires it to exit, i.e. a data/proc statement). These are called "run groups", and "run group processing" is the term you'll see associated with that.

You will find that some people put run; quit; at every point that run; or quit; might be appropriate; that doesn't hurt anything, though it isn't really 'right', either. And there are some cases where it's needed to do that!

One example:

/* first run group*/
proc gplot data=sales;
   title1 "Sales Summary";
   plot sales*model_a;
run;

      /* second run group */
   plot sales*model_b;
run;
quit;

(from run-group processing )

like image 167
Joe Avatar answered Sep 30 '22 07:09

Joe