Hello, I need to combine about ten tables all with different names (example: work.weight, work.diagnosis, work.dose) into one table with a variable that specifies their original table name.
Are you stacking the data or merging the data (adding variables)?
data want;
set weight diagnosis dose indsname=src;
source = src;
run;
Merge (one option)
data want;
merge weight (in=t1) diagnosis (in=t2) dose (in=t3);
by subjid;
src=catx('|', t1, t2, t3);
run;
You likely need to provide more details to get an answer that's more specific to what you need.
@jmmedina252 wrote:
Hello, I need to combine about ten tables all with different names (example: work.weight, work.diagnosis, work.dose) into one table with a variable that specifies their original table name.
Could you define "combine"?? Do you want these tables to be combined horizontally, side by side? Or do you want these tables to be combined vertically, one on top of another? Or do you want something else?
Are you stacking the data or merging the data (adding variables)?
data want;
set weight diagnosis dose indsname=src;
source = src;
run;
Merge (one option)
data want;
merge weight (in=t1) diagnosis (in=t2) dose (in=t3);
by subjid;
src=catx('|', t1, t2, t3);
run;
You likely need to provide more details to get an answer that's more specific to what you need.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.