My final output should like, which o, p, q, r..... are columns, each column for a different population, so this table is a benchmark across all population, it has more than 90 columns.....
Age | o | p | q | r | s | t |
Age: < 18 years | ||||||
Age:18-25 years | ||||||
Age: 26-35 years | ||||||
Age: >35 years | ||||||
Age: Unknown |
I created small tables like this:
Age | o |
Age: < 18 years | |
Age:18-25 years | |
Age: 26-35 years | |
Age: >35 years | |
Age: Unknown |
Age | p |
Age: < 18 years | |
Age:18-25 years |
Age | q |
Age: >25 | |
Age:unknown |
(not all small columns have all the rows for age category, so I am thinking to use left join)
I am wondering the best way to put them together. I can export all small tables into excel and copy paste them, but it will take forever. So I am thinking proc sql left join, but it only allows me to join two tables at once, which is also not too helpful give my 90 columns....
Any suggestion is appreciated!
This is an easy thing for SAS to accomplish, if you switch to MERGE.
Assuming each of your 90 data sets is already sorted by AGE:
data want;
merge pop1-pop90;
by age;
run;
If the data sets have different names, there may not be an easy short-cut for naming them all. You might have to type all 90 data set names into the MERGE statement.
This is an easy thing for SAS to accomplish, if you switch to MERGE.
Assuming each of your 90 data sets is already sorted by AGE:
data want;
merge pop1-pop90;
by age;
run;
If the data sets have different names, there may not be an easy short-cut for naming them all. You might have to type all 90 data set names into the MERGE statement.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.