BookmarkSubscribeRSS Feed
psh23
Fluorite | Level 6

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;

6 REPLIES 6
Reeza
Super User

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. 

psh23
Fluorite | Level 6

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!!

psh23
Fluorite | Level 6

It runs when I do not include census tract.

Reeza
Super User

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;

Reeza
Super User

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.

psh23
Fluorite | Level 6

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 6 replies
  • 2302 views
  • 0 likes
  • 2 in conversation