BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Ihsan-Mahdi
Quartz | Level 8

Hello,

I am trying to calculate age-adjusted mortality rates for a region using the code below:

proc stdrate data = traumadeaths
refdata = ncipop
method = direct
stat = rate(mult = 100) ;
population event = died total = population ;
reference total = population;
strata agegrp /stats;
by edayr;
ods output stdrate = MorRates stRatastats=tester;
Run;

I am getting an error message:

ERROR: The observation values for the TOTAL= variable in the POPULATION statement must be positive.

Can anyone please explain to me what does this error mean?

Thank you 🙂

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

My basic approach would be to write a custom format mapping the existing values to a new group and use that in proc summary to get new totals.

 

Something like this:

data want;
   set have;
   by group;
   diftime= dif(time);
   meanrate= mean(lag(rate),rate);
   if not first.group then value=diftime*meanrate;
   drop diftime meanrate;
run;

proc format library=work;
   value combineage
   1,2,3 = '1-3'
   4     = '4'
   5     = '5'
   6     = '6'
   ;
run;

proc summary data=eventdata nway;
   class agegrp;
   format agegrp combineage. ;
   var eventvar populationvar;
   output out=combinedevent (drop=_:) sum=;
run;

proc summary data=refernecedata nway;
   class agegrp;
   format agegrp combineage. ;
   var eventvar populationvar;
   output out=combinedrefernece (drop=_:) sum=;
run;

The format combines 3 agegroup levels (in this case numeric) into one leaving the others alone.

Then use the combinedevent and combinedreference data sets in Proc Stdrate.

The choice of which levels to combine might depend on which are missing and other knowledge. If the strata are age almost certainly the combinations should represent adjacent ages. The number and pattern of 0 population might bring some art into question and it might be worth trying different formats (one of the reasons to use such, make a different format such as

proc format library=work;
   value combineage_2nd
   1,2   = '1-2'
   3,4   = '3-4'
   5     = '5'
   6     = '6'
   ;
run;

change the format used in the Proc summary to use combineage_2nd. and then run the summary and stdrate code.

 

 

View solution in original post

8 REPLIES 8
ballardw
Super User

Do you have any missing, negative or 0 values for Population in either of your Data= or Refdata= data sets?

Ihsan-Mahdi
Quartz | Level 8

No missings or negatives but many zeros. There weren't many deaths in that data set

 

ballardw
Super User

@Ihsan-Mahdi wrote:

No missings or negatives but many zeros. There weren't many deaths in that data set

 


I would expect EVENTS to possibly be 0. What about the POPULATION variable, as in the number of people in the population for that age strata? Zero for population would indicates that there were no people at all in that age stratification and makes not sense to include in the analysis.

Ihsan-Mahdi
Quartz | Level 8
You are correct! There are a few strata with zero population. Should I remove those from the set before running standardization? And, would that have an effect on accuracy of calculated rates?
ballardw
Super User

I would question why the population is zero in the first place. If looking at a small geographic area then perhaps it makes sense. 

I suspect the best approach would be to combine age strata in both the Event and Reference population data so that there is a population >0 in each of the Event and Reference data sets.

 

A quick experiment with an example in the documentation show things like poulations-time, crude rate , reference crude rate and some estimates can change just dropping one of the strata even when both event and population reference data have 0 counts for the event.

 

 

 

 

Ihsan-Mahdi
Quartz | Level 8
Small geographic area and the population examined is that of trauma patients only. So I think it would make sense for some strata not to be represented.
What would be a code example of combining age strata?
ballardw
Super User

My basic approach would be to write a custom format mapping the existing values to a new group and use that in proc summary to get new totals.

 

Something like this:

data want;
   set have;
   by group;
   diftime= dif(time);
   meanrate= mean(lag(rate),rate);
   if not first.group then value=diftime*meanrate;
   drop diftime meanrate;
run;

proc format library=work;
   value combineage
   1,2,3 = '1-3'
   4     = '4'
   5     = '5'
   6     = '6'
   ;
run;

proc summary data=eventdata nway;
   class agegrp;
   format agegrp combineage. ;
   var eventvar populationvar;
   output out=combinedevent (drop=_:) sum=;
run;

proc summary data=refernecedata nway;
   class agegrp;
   format agegrp combineage. ;
   var eventvar populationvar;
   output out=combinedrefernece (drop=_:) sum=;
run;

The format combines 3 agegroup levels (in this case numeric) into one leaving the others alone.

Then use the combinedevent and combinedreference data sets in Proc Stdrate.

The choice of which levels to combine might depend on which are missing and other knowledge. If the strata are age almost certainly the combinations should represent adjacent ages. The number and pattern of 0 population might bring some art into question and it might be worth trying different formats (one of the reasons to use such, make a different format such as

proc format library=work;
   value combineage_2nd
   1,2   = '1-2'
   3,4   = '3-4'
   5     = '5'
   6     = '6'
   ;
run;

change the format used in the Proc summary to use combineage_2nd. and then run the summary and stdrate code.

 

 

Ihsan-Mahdi
Quartz | Level 8
Thank you so much! This is brilliant 🙂

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 363 views
  • 2 likes
  • 2 in conversation