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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 829 views
  • 2 likes
  • 2 in conversation