BookmarkSubscribeRSS Feed
acschul3
Fluorite | Level 6

Hello,

 

My grad student wrote a SAS program where he kept a small number of variables from a larger dataset and in the same program created some new variables from the ones he kept. 

 

He noticed that the log reported operations performed on missing data when he knew he had none.  To our dismay, we discovered that the newly created variables and renamed variables were moved to the next line of data so that the new variables were now paired with a different id.

 

When I ran the keep statement in a separate program from the steps that created the new variables, this did not happen (see both programs, log, and output in attached document).

 

What went wrong?  The potential for this type of error to wreak havoc on a dataset worries me, so I am very anxious to understand it. 

 

Version is SAS 9.4

 

Many thanks to anyone who can provide insights.

 

A

 

 

 

3 REPLIES 3
PGStats
Opal | Level 21

Lines 338-341: Calculated values are missing because the data is read AFTER the calculations are done. Move the set statement before math operations.

PG
acschul3
Fluorite | Level 6

Many thanks for the quick reply.  A simple error that has great potential for creating problems. 

 

 

PGStats
Opal | Level 21

Indeed! Most errors are reflected in one way or another in the log. Don't hesitate to consult again if you see anything suspicious.

PG

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
  • 690 views
  • 2 likes
  • 2 in conversation