For example
//
DATA tablea;
color="blue"
name="mike"
run;
DATA tableb;
color="pink"
name="sara"
run;
DATA two_data;
set work.tablea
work.tableb;
run;
How do I create a column/variable showing which row belongs to tablea or tableb?
The SET statement INDSNAME option.
DATA two_data; set work.tablea work.tableb indsname=tempvar ; source=tempvar; run;
INDSNAME assigns the name of the source data set to a temporary variable. If you want that in the output set you need to assign it to another variable as above.
The SET statement INDSNAME option.
DATA two_data; set work.tablea work.tableb indsname=tempvar ; source=tempvar; run;
INDSNAME assigns the name of the source data set to a temporary variable. If you want that in the output set you need to assign it to another variable as above.
When I export it to excel, the source column is blank. how do i show it on excel?
Show the LOG of the code you ran to combine the data set and "export to Excel".
Go to the log, copy the text, on the forum open a text window with the </> icon at the top of the message window and then paste the text.
Note that depending on how you "export" you may not have replaced an older version.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.