Happy New Year everyone!
I would like to merge the results of 3 tables as a result of my proc freq data step.
How do I do this?
Example:
proc freq data = step;
tables (site_1 site_2 site_3)*gender / norow nocol nopercent nocum;
run;
where site_1, site_2 and site_3 has three possible options (A,B,C)
and gender = (M,F)
Thanks.
You change the data set
data want;
set have;
site=site_1; output;
site=site_2; output;
site=site_3; output;
run;
and then you run your PROC FREQ on site*gender
@yoyong555 wrote:
I would like to merge the results of 3 tables
This isn't particularly specific about what the "merge" should look like. Describe how such a "merge" should happen. Show us what the merged table should look like.
Hi Paige.
The table should look like this:
Site
Gender A B C Total
F
M
Total
How do we derive the numbers in the cells? What is the math? What is the formula?
I will have three tables as a result of my proc freq datasetp. The tables will look like:
site_1
Gender A B C Total
F 1 1 1 3
M 2 2 0 4
Total 3 3 1 7
site_2
Gender A B C Total
F 3 4 6 13
M 2 0 3 5
Total 5 4 9 18
site_3
Gender A B C Total
F 2 1 1 4
M 4 2 5 11
Total 6 3 6 15
How do I merge the results of these tables to look like this:
site
Gender A B C Total
F 6 6 8 20
M 8 4 8 20
Total 14 10 16 40
Thank you.
You change the data set
data want;
set have;
site=site_1; output;
site=site_2; output;
site=site_3; output;
run;
and then you run your PROC FREQ on site*gender
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.