Run tow different DATA step programs, those are
data t;
set sashelp.class end=j point=j;
output;
stop;
run;
and
data t;
set sashelp.class end=j;
set sashelp.class point=j;
output;
stop;
run;
I get the two different results!
The note for the first program in log window reads "data set work.t has one observation". Does that imply there is no observations read from sashelp.class? If so, why work.t is not empty but has it's one observation with missing values?
The note for the second program in log window reads "Two obervations read from sashelp.class' ,and 'there is one observation in work.t'. Things confusing me is that the observation in work.t is the first observation of sashelp.class rather than that with missing values since the second set statement read a observation with a number 0?
Maxim 2: Read the Log.
You will find that both data steps cause a run-time data ERROR.
In the first data step, since the end= condition is not true (and j is set to zero), the single set tries to read observation zero, which does not exist. All variables in the PDV originating from class remain missing.
In the second data step, the first set works perfectly and populates the PDV. Then it encounters the same ERROR (since j=0), but the variables in the PDV are not overwritten, so you get non-missing values in the output.
Maxim 2: Read the Log.
You will find that both data steps cause a run-time data ERROR.
In the first data step, since the end= condition is not true (and j is set to zero), the single set tries to read observation zero, which does not exist. All variables in the PDV originating from class remain missing.
In the second data step, the first set works perfectly and populates the PDV. Then it encounters the same ERROR (since j=0), but the variables in the PDV are not overwritten, so you get non-missing values in the output.
Sometimes the DATA step did not run because of syntax error,the output data set is still build with 0
observation。 What's the difference between the result in this case and that in the questions i posted just now?
The answer will be in the log. But as it is, the log messages are often not very clear (to a novice, at least), and need interpretation.
My Maxim 2 must therefore be understood as "build your Log-fu" in a larger context. Interpreting the log is a very useful skill, but it has to be acquired the hard way, through experience.
Please post the log of the step that reported a syntax error, but still created a dataset. Use the {i} button for posting logs (available when posting in Rich Text mode) to preserve log content and formatting.
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 25. 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.