I don't think it's a problem with the SAS code, it's just that there are not enough conditional branches. What I'm wondering is if there are records for age 0, 121-179 months, and 121-5474 days, the condition seems to be missing. If the data doesn't exist, it might not be a problem.
If you use if-then-do-end, or select-when-other, I think it will be a little more clear! Please refer to the following (This is untested, so please don't be offended)
/* use select */
select (pt_record);
when("newborn") do;
agegroup = '< 15 yrs';
end;
when("days") do;
if PATIENT_AGE <= 120 agegroup = '< 15 yrs';
end;
when("months") do;
if PATIENT_AGE <= 120 agegroup = '< 15 yrs';
end;
when("years") do;
select;
when( 1 <= PATIENT_AGE <= 15) agegroup = '< 15 yrs';
when(16 <= PATIENT_AGE <= 34) agegroup = '16-34 yrs';
when(35 <= PATIENT_AGE <= 54) agegroup = '35-54 yrs';
when(55 <= PATIENT_AGE ) agegroup = '55+ yrs';
otherwise;/* otherwise is same like else in if-else statements. But it should be written in the select statement, as it will cause errors for other conditions. */
end;
end;
otherwise;
end;
/* use if then else */
if pt_record = "newborn" then agegroup = '< 15 yrs';
else if pt_age_recode in ("years") then begin
if 1 <= PATIENT_AGE <= 15 then agegroup = '< 15 yrs';
else if 16 <= PATIENT_AGE <= 34 then agegroup = '16-34 yrs';
else if 35 <= PATIENT_AGE <= 54 then agegroup = '35-54 yrs';
else if 55 <= PATIENT_AGE then agegroup = '55+ yrs';
end else
if pt_record in ("months" "days") then begin
if PATIENT_AGE <= 120 agegroup = '< 15 yrs';
end;
... View more