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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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