SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

Hello

I want to round up to nearest 500.

For example:

Value 200 should be rounded to 500

Value 400 should be rounded to 500

Value 500 should be stay 500

Value 4400 should be rounded to 4500

Value 4000 should be stay 4000

 

what is the way to doi it please?

3 REPLIES 3
Ksharp
Super User
data have;
input x;
want=ceil(x/500)*500;
cards;
200
400
500
4400
4000
;
PaigeMiller
Diamond | Level 26

My solution:

 

data have;
input x;
want=roundz(x+250,500);
cards;
200
400
500
4400
4000
;
--
Paige Miller

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1617 views
  • 4 likes
  • 4 in conversation