BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
balu_g
Fluorite | Level 6
Compilation phase
SAS reads the descriptor information of each data set that is named in the SET statement and then creates a program data vector that contains all the variables from all data sets as well as variables created by the DATA step.
Execution — Step 1
SAS reads the first observation from the first data set into the program data vector. It processes the first observation and executes other statements in the DATA step. It then writes the contents of the program data vector to the new data set.
The SET statement does not reset the values in the program data vector to missing, except for variables whose value is calculated or assigned during the DATA step. Variables that are created by the DATA step are set to missing at the beginning of each iteration of the DATA step. Variables that are read from a data set are not.
Execution — Step 2
SAS continues to read one observation at a time from the first data set until it finds an end-of-file indicator. The values of the variables in the program data vector are then set to missing, and SAS begins reading observations from the second data set, and so on, until it reads all observations from all data sets.
 
 Variables that are created by the DATA step are set to missing at the beginning of each iteration of the DATA step. Variables that are read from a data set are not.
then 
my question is if the variables that are read from data set are not to set missing, how sas will reading second obeservation values?
 
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

The values are not set to misisng, but the values ARE set to the values read from the input data set when the SET statement executes.

.

Run this little program and see.

 

data sample;
  do i=1 to 3; output; end;
run;

data new ;
   put 'Before SET :' i=;
   set sample;
   put 'After SET: ' i=;
run;

 

View solution in original post

3 REPLIES 3
Reeza
Super User

@balu_g wrote:
 
 
 Variables that are created by the DATA step are set to missing at the beginning of each iteration of the DATA step. Variables that are read from a data set are not.
then 
my question is if the variables that are read from data set are not to set missing, how sas will reading second obeservation values?
 

It's a straight input - the second observations are imported from the data set. 

 

 

Tom
Super User Tom
Super User

The values are not set to misisng, but the values ARE set to the values read from the input data set when the SET statement executes.

.

Run this little program and see.

 

data sample;
  do i=1 to 3; output; end;
run;

data new ;
   put 'Before SET :' i=;
   set sample;
   put 'After SET: ' i=;
run;

 

Astounding
PROC Star

I think we're all saying the same thing, using different words.

 

When the SET statement reads the second (and the third, and the fourth ...) observation from a SAS data set, the values that it reads in replace the values that were in place previously.  There is no need for the processing to re-set those variables to missing.

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