Programming the statistical procedures from SAS

Proc STDRATE error message, missing matched stratum

Reply
Occasional Contributor
Posts: 9

Proc STDRATE error message, missing matched stratum

I am trying to get directly standardized rates using proc stdrate, by census tract and county. When I run my code I get the error message "ERROR: The stratum in the REFDATA= data set, agegrp= 16, does not have a matched
stratum in the DATA= data set" . I added the "notsorted" option becuase I thought the problem might be that census tract is not in ascending order, but it did not fix the problem. 

 

proc sort data=test; by county1 ctract; run;

 

proc stdrate data=test
refdata=USstandard
method=direct
stat=rate(mult=100000)
;
population event=count total=denom;
reference total=standard;
strata agegrp;
by county1 ctract notsorted;
run;

Grand Advisor
Posts: 16,889

Re: Proc STDRATE error message, missing matched stratum

Check if your test dataset is missing a value for age 16 for a census tract. You can add it in as 0. 

 

A quick amd dirty way is to use proc freq with the sparse option to add in the 0. 

Occasional Contributor
Posts: 9

Re: Proc STDRATE error message, missing matched stratum

Hi Reeza,

 

I have run proc means n nmiss, and there are no missing values in the dataset, I think it must have something to do with the sorting of the data?

 

Thank you!!

Occasional Contributor
Posts: 9

Re: Proc STDRATE error message, missing matched stratum

It runs when I do not include census tract.

Grand Advisor
Posts: 16,889

Re: Proc STDRATE error message, missing matched stratum

It's not missing as in ., it's missing as there's no record for age 16. 

 

Try something like the following. 

Does it return the same value?

 

Proc SQL;

select count(distinct censusTract)

from have;

select count(distinct CensusTract)

from have

where age=16;

quit;

Grand Advisor
Posts: 16,889

Re: Proc STDRATE error message, missing matched stratum

Actually I missed that the error message identifies the exact group with the issue. Review your log and the error message again and check if that value exists in your dataset.

Occasional Contributor
Posts: 9

Re: Proc STDRATE error message, missing matched stratum

There are certain census tract / county strata where there are no values for a certain agegroup, because it is such a small subgroup, but those stratum are not included in the data. It seems like it is getting stuck in that it wants a value for every single age group stratum within each census tract / count. It is impossible to include these strata in the dataset because the denominator is zero and it will not run if there are zeros.

Ask a Question
Discussion stats
  • 6 replies
  • 188 views
  • 0 likes
  • 2 in conversation