Working through the SAS Certified Specialist Guide. The book says the last PROC PRINT is the 3rd and last step. From reading the text book, I thought this would have 6 statements with each RUN; being counted as a step. The explanation in the textbook doesn't make sense to me. Can anyone please explain why this code example only has 3 steps?
data user.tables; set work.jobs;run; proc sort data=user.tables; by name; run; proc print data=user.tables; run;
The
run;
creates a step boundary, unless you have a procedure that supports run-group processing, like DATASETS or DS2.
data
or
proc
also create a step boundary, if a step is "active" (not yet finished). Since you have run statements for every step, the following data or proc statements do not create a new boundary, and you have three steps.
proc print data=sashelp.class;
run;
run;
run;
is a single step, followed by two run statements that do nothing.
A datalines block in a data step also creates a step boundary, as you can't have any data step statements after the datalines block.
The
run;
creates a step boundary, unless you have a procedure that supports run-group processing, like DATASETS or DS2.
data
or
proc
also create a step boundary, if a step is "active" (not yet finished). Since you have run statements for every step, the following data or proc statements do not create a new boundary, and you have three steps.
proc print data=sashelp.class;
run;
run;
run;
is a single step, followed by two run statements that do nothing.
A datalines block in a data step also creates a step boundary, as you can't have any data step statements after the datalines block.
@Kurt_Bremser Thank you for the explanation. Your break down makes sense. However, I was confused by the example below from the text, in which it labels the "run" after "data" as a separate step (Step #3). Why isn't that "run" considered part of the "data" step. In essence, why is this considered to have 4 steps and not 3 vs. my original post, which is said to have 3 steps. The code in my original post, the "data" step is the first step, and includes the "run". This seems contradictory to my SAS beginner's mind.
title1 'June Billing'; /*#1*/ data work.junefee; /*#2*/ set cert.admitjune; where age>39; run; /*#3*/ proc print data=work.junefee; /*#4*/
run;
@DavidBrown wrote:
@Kurt_Bremser Thank you for the explanation. Your break down makes sense. However, I was confused by the example below from the text, in which it labels the "run" after "data" as a separate step (Step #3). Why isn't that "run" considered part of the "data" step. In essence, why is this considered to have 4 steps and not 3 vs. my original post, which is said to have 3 steps. The code in my original post, the "data" step is the first step, and includes the "run". This seems contradictory to my SAS beginner's mind.
title1 'June Billing'; /*#1*/ data work.junefee; /*#2*/ set cert.admitjune; where age>39; run; /*#3*/ proc print data=work.junefee; /*#4*/
run;
From my POV, that is flat wrong. These are two(!) steps and a single Global Statement.
@Kurt_Bremser Thank you. I thought I was going crazy. In essence they are saying there is a difference between these 2 steps below, when there isn't.
**Example #1 (one step)**;
data user.tables; set work.jobs;run; **Example #2 (two steps)**;
data work.junefee; set cert.admitjune;
where age>39;
run;
Actually it's quite simple (just to rephrase Kurt Bremser's reply):
Roughly speaking, a DATA step looks like this
data ...;
...
run;
and a PROC step looks like this
proc ...;
...
run;
or, for a few procedures, like this
proc ...;
...
quit;
So, this simplified ("first-lesson like") statement already provides the answer to your question.
Notable exceptions (not applicable to your example) are
@FreelanceReinhard Thank you. I'm starting to get it, but still don't get, why in my second example "run;" in step 3 is considered and individual step. Why is it not part of the data step? Sorry if I am being obtuse.
@Kurt_Bremser wrote:
From my POV, that is flat wrong. These are two(!) steps and a single Global Statement.
Exactly. The assignment of a separate number to the global TITLE1 statement clearly indicates that these numbers do not count steps.
Also, the fact that an omitted RUN (or QUIT) statement can be "implied" by the beginning of a new step (as I mentioned earlier) does not mean that the combination of a mere RUN (or QUIT) statement and the beginning of a new step constitutes two steps.
@FreelanceReinhard The text considers the global statement as an "outside" step, but a step nonetheless.
Per the SAS Certified Specialist Prep Guide Chapter 2:
1 The TITLE statement is a global statement. Global statements are typically outside steps and do not require a RUN statement.
Here is their explanation on why my first example as 3 steps. However, from my POV I still don't see why:
When it encounters a DATA, PROC, or RUN statement, SAS stops reading statements and executes the previous step in the program. This program contains one DATA step and two PROC steps, for a total of three program steps.
.
A global statement is NEVER a step. See the definition of "step" by SAS themselves:
@DavidBrown wrote:
(...) Global statements are typically outside steps ...
Well, English is not my native language, but I understand this sentence like "Global statements are typically (used) outside of steps." (But for some global statements, e.g., TITLE statements, it's not uncommon to use them inside [of] steps.) There is no such thing as an "outside step" -- only DATA and PROC steps.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: