- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It runs when I do not include census tract.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.