BookmarkSubscribeRSS Feed
GARYV
Fluorite | Level 6

I have a five age categories and want to create a plot for age-standardized rate for a disease over six years. Below is my program but it is giving me an error . Is it because of having six years of data, if so is there any way to overcome this error?

Thank you

 

ERROR: At most two study populations can be used for METHOD=DIRECT.

data USASTDRATE;
format AgeGroup 2. AgeGroupDesc $5. USA2000 comma12.;
informat USA2000 comma12.; 
input AgeGroup AgeGroupDesc $ USA2000;
cards;
1 0-17 70,781,454
2 18-44 108,151,050
3 45-64 60,991,658
4 65-74 18,135,514
5 75+ 16,573,966
;
data CAT1;
format  year AgeGroup 8. events population comma12.;
input Year  AgeGroup events population;
cards;
2006 1 6 6511656
2006 2 130 9332590

-----
----
2011 5 789 1567143
; run;
Proc sort data=cat1;
by year; run;
ods table STDRATE=Age_ADJ.cat1;
proc stdrate data=cat1  
                   refdata=USASTDRATE irect  
                  stat=rate (mult=100000) 
                  CL=Normal 
METHOD=DIRECT ; population group=year event=events total=population ; reference total=USA2000; strata agegroup; run;

 

5 REPLIES 5
Reeza
Super User

Can you post your exact log?

 

I get a very different error message. 

There is no IRECT option as far as I can see within PROC STDRATE from the documentation and you don't specify a method. 

 


@GARYV wrote:

I have a five age categories and want to create a plot for age-standardized rate for a disease over six years. Below is my program but it is giving me an error . Is it because of having six years of data, if so is there any way to overcome this error?

Thank you

 

ERROR: At most two study populations can be used for METHOD=DIRECT.

data USASTDRATE;
format AgeGroup 2. AgeGroupDesc $5. USA2000 comma12.;
informat USA2000 comma12.; 
input AgeGroup AgeGroupDesc $ USA2000;
cards;
1 0-17 70,781,454
2 18-44 108,151,050
3 45-64 60,991,658
4 65-74 18,135,514
5 75+ 16,573,966
;
data CAT1;
format  year AgeGroup 8. events population comma12.;
input Year  AgeGroup events population;
cards;
2006 1 6 6511656
2006 2 130 9332590

-----
----
2011 5 789 1567143
; run;
Proc sort data=cat1;
by year; run;
ods table STDRATE=Age_ADJ.cat1;
proc stdrate data=cat1  
                   refdata=USASTDRATE irect  
                  stat=rate (mult=100000) 
                  CL=Normal 
                  ;
 

      population    group=year  event=events total=population ; 
      reference total=USA2000; 
      strata agegroup;
    
      
run;

 


 

GARYV
Fluorite | Level 6

HI REEZA,

I WAS MISSING 'METHOD= DIRECT 'code, have updated code

StatDave
SAS Super FREQ

I assume that your code actually had METHOD=DIRECT and that the dashes in the second DATA step just indicate that you have more data there. Given that, it is true that the direct method in PROC STDRATE only handles two groups. You could make comparisons by using a WHERE statement to select just two groups at a time and using METHOD=MH instead of DIRECT. Then simply run the procedure several times for each pair of groups.

GARYV
Fluorite | Level 6

Hello,

It is very tedious to do as I will be running this code for multiple groups and not only for years

Reeza
Super User

 

You could make it into a macro relatively easily. 

I wrote an example of that last week here, 

https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md

 

 

Or you can try a BY statement without a GROUP statement. You'll get slightly different outputs, but you get the standardized rates as well, just not also strata specific though there's probably an option to enable that as well.

 

Note the ODS OUTPUT statement with the WANT data set and the estimates. You likely want that information in a single table anyways.

 

Please make sure you test and verify this methodology and the numbers you get are correct.  I don't have time to do that research myself now, but believe it's a valid approach for you issue.

 

Good Luck!

 

PS. If you provide full data in the future it's easier to work with your data. If I have to type it out, I'll likely resort to using the SAS data examples which means it doesn't match your data structure and you have to remap. It helps with the understanding but also slows things down a bit. 

 

data Alaska;
   State='Alaska';
   input Sex $ Age $ Death PYear:comma7.;
   datalines;
Male    00-14   37   81,205
Male    15-34   68   93,662
Male    35-54  206  108,615
Male    55-74  369   35,139
Male    75+    556    5,491
Female  00-14   78   77,203
Female  15-34  181   85,412
Female  35-54  395  100,386
Female  55-74  555   32,118
Female  75+    479    7,701
;

data Florida;
   State='Florida';
   input Sex $ Age $ Death:comma6. PYear:comma9.;
   datalines;
Male    00-14   1,189  1,505,889
Male    15-34   2,962  1,972,157
Male    35-54  10,279  2,197,912
Male    55-74  26,354  1,383,533
Male    75+    42,443    554,632
Female  00-14     906  1,445,831
Female  15-34   1,234  1,870,430
Female  35-54   5,630  2,246,737
Female  55-74  18,309  1,612,270
Female  75+    53,489    868,838
;

data TwoStates;
   length State $ 7.;
   set Alaska Florida;
run;

data US;
   input Sex $ Age $ PYear:comma10.;
   datalines;
Male    00-14  30,854,207
Male    15-34  40,199,647
Male    35-54  40,945,028
Male    55-74  19,948,630
Male    75+     6,106,351
Female  00-14  29,399,168
Female  15-34  38,876,268
Female  35-54  41,881,451
Female  55-74  22,717,040
Female  75+    10,494,416
;


title 'Using By groups';
proc stdrate data=TwoStates
             refdata=US
             method=direct
             stat=rate(mult=1000)
             effect
             plots(only)=(dist effect)
             ;
   by state;
   population  event=Death total=PYear;
   reference  total=PYear;
   strata Sex Age / effect;

   ods output stdrate=want;
run;

title 'Using GROUP = option';
proc stdrate data=TwoStates
             refdata=US
             method=direct
             stat=rate(mult=1000)
             effect
             plots(only)=(dist effect)
             ;
   population group=state event=Death total=PYear;
   reference  total=PYear;
   strata Sex Age / effect;
run;

 


@GARYV wrote:

Hello,

It is very tedious to do as I will be running this code for multiple groups and not only for years


 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 2684 views
  • 0 likes
  • 3 in conversation