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 2025: Register Now

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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