i tried up whith this condition.
But the 89 series are come up as null ... Why?
data cre_epi;
set creatin7;
if epi_1 ge 90 then
epi_1_stage =1;
if epi_1 ge 60 and epi_1 le 89 then
epi_1_stage =2;
if epi_1 ge 30 and epi_1 le 59 then
epi_1_stage =3;
if epi_1 ge 15 and epi_1 le 29 then
epi_1_stage =4;
if epi_1 lt 15 then
epi_1_stage =5;
if epi_1 =. then
epi_1_stage =.;
if epi_5 ge 90 then
epi_5_stage =1;
if epi_5 ge 60 and epi_5 le 89 then
epi_5_stage =2;
if epi_5 ge 30 and epi_5 le 59 then
epi_5_stage =3;
if epi_5 ge 15 and epi_5 le 29 then
epi_5_stage =4;
if epi_5 lt 15 then
epi_5_stage =5;
if epi_5 =. then
epi_5_stage =.;
run;
mno | epi_1 | epi_5 | epi_1_stage | epi_5_stage |
124438 | 75.387 | 89.875 | 2 | . |
124412 | 82.071 | 82.071 | 2 | 2 |
112956 | 89.944 | . | . | . |
Very simple. 89.875 is NOT less or equal to 89.
Use this type of conditions:
if epi_1 ge 60 and epi_1 lt 90 then
Very simple. 89.875 is NOT less or equal to 89.
Use this type of conditions:
if epi_1 ge 60 and epi_1 lt 90 then
The value of 89.875 doesn't satisfy any of your conditions. It is not greater than 90. It is not between 60 and 89. etc.
This looks more like a job for formats anyways.
proc format; value creatin 1-15=5 15-30=4 30-60=3 60-90=2 90-high=1 other=.; run; data want; set have; format epi_1 epi_5 creatin.; run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.