DATALINES Step Boundary

4

Know your step boundaries!

Will the DATA Step below execute as is?

data a;
      infile 'c:\temp\myfile.txt';
      input x y z;

No.  A RUN statement or other step boundary is required to mark the end of the DATA Step and cause the step to execute.

Will the DATA Step below execute as is?

data a;
      infile datalines;
      input x y z;
datalines;
1 2 3
4 5 6
;

Yes.  The DATALINES statement marks the end of DATA Step statements. The semi-colon after the data lines causes the DATA Step to execute.

Is it OK to put a RUN statement after the semi-colon following the data lines?

data a;
      infile datalines;
      input x y z;
datalines;
1 2 3
4 5 6
;
run;

Yes.  The RUN statement is harmless but unnecessary. An extra step boundary is not required.  The RUN statement has no effect.

Tags
Share

About Author

Jim Simon

Principal Technical Training Consultant

Jim Simon is a principal instructor and course developer for SAS Education. Jim has a bachelor's degree from UCLA and a master's degree from California State University at Northridge. Prior to joining the SAS Irvine office in 1988, Jim was an instructor at Ventura College and a SAS programmer at The Medstat Group in Santa Barbara. Jim's areas of specialization include the DATA step, application development, web enablement, and the SAS macro language. A native of Southern California, Jim enjoys anything in the warm California sun. On weekends, Jim loves jumping in his Corvette, turning up the stereo, and cruising Pacific Coast Highway, top down, South to Laguna Beach or North to his old home town, Santa Barbara.

4 Comments

  1. Clint Rickards on

    To expand on Michelle Holmes comment, the first DATA step will also execute in a batch environment because the end of the program file also marks the end of the DATA step. It will also run in any environment if there is another step following it.

  2. Is it OK not to use infile in the following data step?

    data a;
    infile datalines;
    input x y z;
    cards;
    1 2 3
    ;
    Yes. The INFILE statement here is harmless but unnecessary. :-)

  3. You are right in saying that a "run" statement is not needed when "datalines" is used. Nevertheless, it is a good programming practice to use "run" for the sake of consistency and readability.

  4. I think a caveat to your questions above is the SAS environment in which you run the program... The first program won't run in Foundation SAS as you point out but will in SAS Enterprise Guide due to the internal SAS statements SAS Enterprise Guide submits after every request sent.

Back to Top