Hi all. I'm trying to figure out how to create a single table for output instead of a bunch of tables I need to merge. This is how the data looks:
ID# #chronic conditions Risk Consent
1 0 0 0
2 1 1 0
3 0 1 1
4 2 1 0
5 2 0 0
key-
Risk: 1=high, 0=low Consent: 1=yes 0=no
chronic conditions can be 0-2
I want a table that looks like this:
#chronic conditions | Total# | #people high risk | # people consented
0 2 1 1
1 1 1 0
2 2 1 0
Total#= Total amount of people with n chronic condition
#people high risk= count of people with risk= 1 for each chronic condition
#people consented= count of people with consent= 1 for each chronic condition
@jmmedina25 wrote:
Hi all. I'm trying to figure out how to create a single table for output instead of a bunch of tables I need to merge. This is how the data looks:
ID# #chronic conditions Risk Consent
1 0 0 0
2 1 1 0
3 0 1 1
4 2 1 0
5 2 0 0
key-
Risk: 1=high, 0=low Consent: 1=yes 0=no
chronic conditions can be 0-2
I want a table that looks like this:
#chronic conditions | Total# | #people high risk | # people consented
0 2 1 1
1 1 1 0
2 2 1 0
Total#= Total amount of people with n chronic condition
#people high risk= count of people with risk= 1 for each chronic condition
#people consented= count of people with consent= 1 for each chronic condition
This looks like a job for PROC SUMMARY
proc summary data=have nway;
class chronic_conditions;
var risk consent;
output out=want sum=no_people_high_risk no_people_consented;
run;
Will you please paste few rows of data in a readily usable form? If the data is information sensitive in nature, provide an example dataset inside a DATA block.
Thank you.
@jmmedina25 wrote:
Hi all. I'm trying to figure out how to create a single table for output instead of a bunch of tables I need to merge. This is how the data looks:
ID# #chronic conditions Risk Consent
1 0 0 0
2 1 1 0
3 0 1 1
4 2 1 0
5 2 0 0
key-
Risk: 1=high, 0=low Consent: 1=yes 0=no
chronic conditions can be 0-2
I want a table that looks like this:
#chronic conditions | Total# | #people high risk | # people consented
0 2 1 1
1 1 1 0
2 2 1 0
Total#= Total amount of people with n chronic condition
#people high risk= count of people with risk= 1 for each chronic condition
#people consented= count of people with consent= 1 for each chronic condition
This looks like a job for PROC SUMMARY
proc summary data=have nway;
class chronic_conditions;
var risk consent;
output out=want sum=no_people_high_risk no_people_consented;
run;
This worked like a charm; thank you so much!
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.