BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kmin87
Fluorite | Level 6

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?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

 

 

View solution in original post

3 REPLIES 3
ballardw
Super User

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.

 

 

kmin87
Fluorite | Level 6

When I export it to excel, the source column is blank. how do i show it on excel?

ballardw
Super User

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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