Desktop productivity for business analysts and programmers

How do I identify non-integers in a WHERE statement?

Reply
Contributor
Posts: 50

How do I identify non-integers in a WHERE statement?

I'm doing some quality checking on a data set I have and want to include in a where statement some command to identify numbers that are not integers over a certain interval.

Particularly I'm trying to do this for the variable for maternal age (mage).  How do I pull out observations where the mage variable is not an integer?

Thanks.

CODING:

PROC PRINT DATA=work.DATA;

WHERE 

(dead NE 1 AND dead NE 0) OR

(sex NE 1 AND sex NE 0) OR

(rc_gp NE 1 AND rc_gp NE 2 AND rc_gp NE 3 AND rc_gp NE 4 AND rc_gp NE 5) OR

(hisp NE 0 AND hisp NE 1) OR

(8 GE mage OR mage GE 85)

(medu LE 5 OR medu GT 17);

RUN;

Respected Advisor
Posts: 4,821

Re: How do I identify non-integers in a WHERE statement?

mage NE INT(mage)

PG

PG
Respected Advisor
Posts: 3,156

Re: How do I identify non-integers in a WHERE statement?

Or :

mage ne floor(mage)

mage ne ceil(mage)

Haikuo

Valued Guide
Posts: 3,208

Re: How do I identify non-integers in a WHERE statement?

May be a quite different approach:

- suppose you have SAS-formats defined to the wanted valid integer values

  For the variable sex:

       0='M'  or male, 

       1='F' or female m ,

       9= ' ' missing ,

       other= "-" invalid ... the meaning.

- Testing on the formatted value of you variable will give a very strict data quality approach

  Use the put or input function to recode/format values.

Remember that numbers in SAS are always of type floating. The storage needed is requiring normally 8 bytes.
Sometimes 1 is not 1 but nearly 1 and you don't see it. It can be a reason of a failed assignment. Rounding up can be necessary.

To circumvent the floating issues you can think about having it set as character-types.  0, 1 9 can be perfectly stored and processed as character-values. The requirement is you don't  need to calculate with these values.  Just counting the values in a population is no problem.

---->-- ja karman --<-----
Ask a Question
Discussion stats
  • 3 replies
  • 1548 views
  • 0 likes
  • 4 in conversation