BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
mariko5797
Pyrite | Level 9

I know there's a way to do this but I cannot remember what the option is called and am also having trouble looking it up.

I essentially want to stack multiple datasets and have a column created with their names in it so I can keep track of which data belongs to which dataset.

 

data have1;
 var1 = 'A'; var2= 'BC'; var3= 1;
data have2;
 var1 = 'D'; var2= 'EF'; var3= 2;
data have;
 set have1 have2;
run;

data want;
 input dsn $ var1 $ var2 $ var3 @@;
 cards;
 have1 A BC 1
 have2 D EF 2
 ;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

 Use the INDSNAME (Input DataSet Name) option

 

 

data have;
    length source src $40.;
    set have1 have2 indsname = source;
    src=source;
run;

 

 

 

 

 

View solution in original post

2 REPLIES 2
Reeza
Super User

 Use the INDSNAME (Input DataSet Name) option

 

 

data have;
    length source src $40.;
    set have1 have2 indsname = source;
    src=source;
run;

 

 

 

 

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 2340 views
  • 0 likes
  • 3 in conversation