DATA Step, Macro, Functions and more

data step processing in sas during concatenation

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

data step processing in sas during concatenation

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?
 

Accepted Solutions
Solution
‎10-22-2016 08:39 PM
Super User
Super User
Posts: 6,499

Re: data step processing in sas during concatenation

[ Edited ]

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


All Replies
Super User
Posts: 17,816

Re: data step processing in sas during concatenation


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. 

 

 

Solution
‎10-22-2016 08:39 PM
Super User
Super User
Posts: 6,499

Re: data step processing in sas during concatenation

[ Edited ]

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;

 

Super User
Posts: 5,081

Re: data step processing in sas during concatenation

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.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 226 views
  • 2 likes
  • 4 in conversation