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 open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.