Quit vs Run statements in SAS

后端 未结 1 1903
栀梦
栀梦 2021-02-13 23:43

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 dataset

相关标签:
1条回答
  • 2021-02-14 00:23

    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 )

    0 讨论(0)
提交回复
热议问题