data a;
set sashelp.class sashelp.class;output;
set sashelp.class;output;
run;
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: There were 1 observations read from the data set SASHELP.CLASS.
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.A has 39 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds
Can someone explain why we getting 1 for observation for 2nd dataset I guess we get total of 38 observations I just confuse in it..
data a;
set sashelp.class(in=a) sashelp.class(in=b);aa=a; bb=b; output;
set sashelp.class(in=c); cc=c; output;
run;
proc print; run;
When you have doubts about what SAS is doing, ask SAS to explain. So I set binary flags so that you can see from where each observation originates. Near the end of processing, William is read from the first mention of the data set. Then it is read from the last. Then on the next pass, Alfred is read from the second data set, then SAS hits end of file on the last data set. So only one obs is read from the second mention.
Hi,
Read this document under the heading Combining SAS Data Sets
"If the data sets contain common variables, the values that are read in from the last data set replace the values that were read in from earlier ones. "
The notes seem pretty clear. You read in 39 observations and wrote out 39 observations.
For the first 19 times through the data step loop you read and write twice and so generate 38 output records.
But on the 20th time through the loop the first SET/OUTPUT pair runs and writes the 39th output record, but the data step stops when it reads past the end of the data in the second SET statement.
The first SET statement has an incoming stream of up to 38 obs. The second has 19. So there are 19 iterations of the data step in which both SETs read a record.
On the 20th iteration, the first SET is successful (but at that point is just starting its 2nd data set file. But the 20th iteration also exceeds the limit of the 2nd SET, thereby terminating the data step. So the first SET reads 19 +1, and the second reads 19.
Good question.
I just want say.
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
data a;
set sashelp.class sashelp.class;output;
set sashelp.class;output;
run;
NOTE: There were 1 observations read from the data set SASHELP.CLASS.
data a;
set sashelp.class sashelp.class;output;
set sashelp.class;output;
run;
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
data a;
set sashelp.class sashelp.class;output;
set sashelp.class;output;
run;
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.
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.