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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.