11-22-2016 12:12 AM
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
population event=count total=denom;
by county1 ctract notsorted;
11-22-2016 03:04 AM
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.
11-22-2016 11:09 AM
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?
11-22-2016 01:48 PM
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?
select count(distinct censusTract)
select count(distinct CensusTract)
11-22-2016 03:21 PM
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.
11-22-2016 04:57 PM
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.