BookmarkSubscribeRSS Feed
mantubiradar19
Quartz | Level 8

I have a dataset containing binary variable DIAGNOSIS (0 & 1 for control and case) and the range of AGE is from 20 ~ 80. I'm interested to see the distribution (# of cases & controls) in various age groups with an interval of 10 years. (20~30, 30~40, 50~60, 60~70, etc). 

 

Please suggest to me how to obtain suitable tables and plots to visualize my data. 

 

PS: I have attached an example 

Distribution-of-cases-and-controls-by-their-age-groups.jpg

Thanks in advance

2 REPLIES 2
PetriRoine
Pyrite | Level 9

Hello @mantubiradar19 

 

The following instructions are based on the assumptions that the data is aligned like this:

Age Diagnosis
37 0
76 1
29 0

 

Steps taken

  1. Create Age group category
    Use the Custom category feature to create age buckets.
    Capture1.PNG
  2. Create Cases measure:
    Use the New Calculated Item feature to calculate number cases.
    IF ( 'Diagnosis'n = 1 )
    RETURN 1
    ELSE 0
  3. Create Controls measure:
    Use the New Calculated Item feature to calculate number of controls.
    IF ( 'Diagnosis'n = 0 )
    RETURN 1
    ELSE 0

     

  4. Create Total measure:
    Use the New Calculated Item feature to calculate number of cases + controls.
    'Cases'n + 'Controls'n

     

  5. Create Cases %, Controls %, and Total %
    Use the New Calculated item feature to calculate three new aggregated measures.
    Cases %
    Sum [_ByGroup_] ('Cases'n) / Sum [_ForAll_] ('Cases'n)
    Controls %
    Sum [_ByGroup_] ('Controls'n) / Sum [_ForAll_] ('Controls'n)
    Total %
    Sum [_ByGroup_] ('Total'n) / Sum [_ForAll_] ('Total'n)

  6. Utilize Crosstab object and assign roles as below
    Capture2.PNG

I hope this helps.

 

Best regards,

Petri

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!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1227 views
  • 2 likes
  • 2 in conversation