BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Steve1964
Obsidian | Level 7

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? 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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.

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

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.

Steve1964
Obsidian | Level 7

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?

 

 

Kurt_Bremser
Super User

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 819 views
  • 1 like
  • 2 in conversation