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

In need to round down to the nearest whole number or simply strip everything to the right of the decimal in a numeric field.  Example:

have need
1.2 1
0.1 0
10 10
1 ACCEPTED SOLUTION

Accepted Solutions
mohamed_zaki
Barite | Level 11

Use the FLOOR function to round down to the next integer.

 

data a;
  input have;
  need=floor(have);
datalines;
1.2
0.1
10 123.456 34 5.1111 7.68 10.98 -3.1 -19.0 -4.8 ; proc print; run;

 

View solution in original post

2 REPLIES 2
mohamed_zaki
Barite | Level 11

Use the FLOOR function to round down to the next integer.

 

data a;
  input have;
  need=floor(have);
datalines;
1.2
0.1
10 123.456 34 5.1111 7.68 10.98 -3.1 -19.0 -4.8 ; proc print; run;

 

advoss
Quartz | Level 8

Remember that the floor function gives you the next lower number, so 3.1 yields 3 and -3.1 yields -4.  The int function will give you 3 and -3 respectively.  So, choose the one that meets your specific needs.

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
  • 2 replies
  • 1695 views
  • 6 likes
  • 3 in conversation