BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Ronein
Meteorite | Level 14

Hello

I want to create a new column called X_New .

The value in X_New column will be the rounded down value of column X.

The expected values are:

X=4000 ,X_New=4000

X=4200,X_New=4000

X=4500, X_New=4000

X=4600, X_New=4000

X=4900, X_New=4000

X=5000, X_New=5000

X=5100, X_New=5000

 

What is the way to round down by 1000 ?

 

data have;
input x;
cards;
4000
4200
4500
4600
4900
5000
5100
0
.
;
Run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Use the FLOOR function

 

x_new=floor(x/1000)*1000;
--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Use the FLOOR function

 

x_new=floor(x/1000)*1000;
--
Paige Miller
Rick_SAS
SAS Super FREQ

As Paige says, the FLOOR function will round all numbers toward negative infinity.

 

For negative values, some people prefer to round toward zero. If you want to round toward zero, use the INT function:

x_new=int(x/1000)*1000;

 For more information about rounding, see 

"Rounding up, rounding down"

 

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 122 views
  • 4 likes
  • 3 in conversation