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

Innovate_SAS_Blue.png

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. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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