BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jmmedina25
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@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;
--
Paige Miller

View solution in original post

3 REPLIES 3
koyelghosh
Lapis Lazuli | Level 10

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.

PaigeMiller
Diamond | Level 26

@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;
--
Paige Miller
jmmedina25
Obsidian | Level 7

This worked like a charm; thank you so much!

sas-innovate-2024.png

 

Time is running out to save with the early bird rate. Register by Friday, March 1 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 434 views
  • 0 likes
  • 3 in conversation