Solved
Contributor
Posts: 33

# If condition error

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 . . .

Accepted Solutions
Solution
3 weeks ago
Super User
Posts: 10,280

## Re: If condition error

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 ``
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

All Replies
Solution
3 weeks ago
Super User
Posts: 10,280

## Re: If condition error

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 ``
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Posts: 3,065

## Re: If condition error

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.

--
Paige Miller
Super User
Posts: 9,599

## Re: If condition error

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;
```
☑ This topic is solved.