BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mmaskew
Calcite | Level 5

I have a dataset with a numeric variable that has the numeric value of several different lab tests. Some of these are whole integers (25 or 100 etc) but some are with decimals (25.6849 or 100.329 etc). I need to restrict this dataset to the observations where this variable is represented by whole numbers only. I don’t want it to round the decimals to whole numbers, I want to delete any observation that has a decimal value.  I have tried converting it to a text variable with PUT not specifying decimal places but SAS rounds the values out to whole numbers in the outputted text variable. Then I specified decimal places in the PUT function so I can pick out the decimal with substring function but for some reason, SAS still rounds up the number and adds 0 after the decimal so that 239.199965 becomes 239.200000 which doesn’t help me.

 

Any suggestions?

Many thanks all

1 ACCEPTED SOLUTION

Accepted Solutions
2 REPLIES 2
Kurt_Bremser
Super User

Use a where condition:

data have;
input x1;
cards;
1
2
1.5
;
run;

data want;
set have;
where int(x1) = x1;
run;

proc print data=want noobs;
run;

Result:

 x1

  1
  2
mmaskew
Calcite | Level 5

Awesome! Thanks so much for the quick response! That worked great..

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!

How to Concatenate Values

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.

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
  • 2 replies
  • 1321 views
  • 0 likes
  • 2 in conversation