BookmarkSubscribeRSS Feed
mconover
Quartz | Level 8

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;

3 REPLIES 3
PGStats
Opal | Level 21

mage NE INT(mage)

PG

PG
Haikuo
Onyx | Level 15

Or :

mage ne floor(mage)

mage ne ceil(mage)

Haikuo

jakarman
Barite | Level 11

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 5240 views
  • 0 likes
  • 4 in conversation