BookmarkSubscribeRSS Feed
bhong
Calcite | Level 5

Hi, I'm trying to use PROC STDRATE to get standardized mortality rates. I have two datasets, one of them being the reference dataset. I've tried to run the following code, but get various warning and error messages. I have no idea what I'm doing wrong, so any help would be great!

 

 

proc stdrate data = mort_rate_race
				refdata = ref_race
				method = direct
				stat = rate (mult = 100)
				effect = ratio
				plots(only) = effect
				;
	population event = total_death total = total_risk_period;
	reference total = total_pop;
	strata race_new / effect;
run;

 

 

However, I get the following warning/error messages:

 

 

WARNING: You must enable ODS graphics before requesting plots.
WARNING: The GROUP= option in the POPULATION statement is required for the EFFECT option. The option is not used.
WARNING: The stratum in the REFDATA= data set, race_new=	Asian, does not have a matched stratum in the DATA= data set.
WARNING: The stratum in the REFDATA= data set, race_new=	Black, does not have a matched stratum in the DATA= data set.
WARNING: The stratum in the REFDATA= data set, race_new=	Hispanic, does not have a matched stratum in the DATA= data set.
WARNING: The stratum in the REFDATA= data set, race_new=	Other, does not have a matched stratum in the DATA= data set.
WARNING: The stratum in the REFDATA= data set, race_new=	White, does not have a matched stratum in the DATA= data set.
ERROR: The reference total is missing in the stratum race_new=Asian.

I'm not sure why, as I've looked at my two datasets and everything seems to be there. Here are the two datasets:

 

 

Capture.PNG

1 REPLY 1
FreelanceReinh
Jade | Level 19

Hi @bhong,

 

I'm not very familiar with PROC STDRATE, but a quick comparison with Example 110.1 Comparing Directly Standardized Rates from the procedure documentation reveals an important difference: There, they compare two populations (Alaska and Florida) which is why they need to standardize (using data for the U.S. as the reference population). Your MORT_RATE_RACE dataset, however, contains data for only one population. This means that all options involving "EFFECT" are not applicable because they apply "only when METHOD=DIRECT with two study populations ... are required" (documentation). So, you should delete or comment out the EFFECT= and PLOTS= options of the PROC STDRATE statement as well as the EFFECT option of the STRATA statement.

 

Also, you should make sure that the values in variable TOTAL_POP have the same unit (e.g. person-years) as those in variable TOTAL_RISK_PERIOD.

 

Moreover, you have a data issue: It looks like variable RACE_NEW in dataset REF_RACE contains tabs, leading blanks or other white space characters, which cause the mismatches mentioned in five of the warnings (e.g. '   Asian' does not match 'Asian'). So, you need to resolve these issues, e.g., with a DATA step like

data ref_race;
set ref_race;
race_new=compress(race_new,,'ka');
run;

or, even better, in the step that creates REF_RACE in the first place. If REF_RACE values in MORT_RATE_RACE also have leading blanks, you need to remove them in the same way.

 

Finally, to enable ODS graphics (for the implied default plot request PLOTS=RATE) use the ODS GRAPHICS statement.

ods graphics;

proc stdrate data = mort_rate_race
    refdata = ref_race
    method = direct
    stat = rate (mult = 100)
    ;
  population event = total_death total = total_risk_period;
  reference total = total_pop; /* <-- please check the unit of TOTAL_POP */
  strata race_new;
run;

The above code should run without errors or warnings. It's your responsibility to check if the results make sense.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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
  • 1 reply
  • 1398 views
  • 0 likes
  • 2 in conversation