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

value=round(3.340422,1.5);

its not round to 3.58 .

could you plz help me by use  round to get around 3.58 value in that statement.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Note that the second parameter is supposed to be the multiple you want. Ie you want 3.34... rounded to the nearest 1.5. 

Multiples of 1.5 are 0, 1.5, 3, 4.5 so the result will be 3. 

 

If you want values of 3.58 you need to have some multiple of that number. So dividing it by 2, gives 1.79.

 

Multiples of 1.79 are 0, 1.79, 3.58 and 3.34 will round to 3.58.

 

However, I'm having a hard time seeing how this is actually what you would want. But it will answer the question you've asked.

 

X = round(3.340422, 1.79);

View solution in original post

5 REPLIES 5
Reeza
Super User

@vinod4842 Note that I've modified your subject line to Round as it's slightly more descriptive than 'SAS'. Please recall that our goal on here is to both answer your question and future users. 

 

vinod4842
Fluorite | Level 6

data ds;

infile datalines;

input ID CASH_TURNOVER  COUNTRY;

CASH_TURNOVER=round(CASH_TURNOVER,);

DATALINES;

702272 3.340422 IND

705651 2.371976 IND

;

RUN;

I WANT TO CHANGE THE CASH_TURNOVER  VARIABLE FIRST VALUE TO 3.58, WHAT CAN I DO WITH THAT ROUND OPTION

I GETTING SO MANY GARBAGE VALUE.

 

Reeza
Super User

@vinod4842 wrote:

 

I WANT TO CHANGE THE CASH_TURNOVER  VARIABLE FIRST VALUE TO 3.58, WHAT CAN I DO WITH THAT ROUND OPTION

I GETTING SO MANY GARBAGE VALUE.

 


WHAT'S THE RULE? WHY IS IT 3.58 AND NOT 3.59, OR 3.78? 

Reeza
Super User

Note that the second parameter is supposed to be the multiple you want. Ie you want 3.34... rounded to the nearest 1.5. 

Multiples of 1.5 are 0, 1.5, 3, 4.5 so the result will be 3. 

 

If you want values of 3.58 you need to have some multiple of that number. So dividing it by 2, gives 1.79.

 

Multiples of 1.79 are 0, 1.79, 3.58 and 3.34 will round to 3.58.

 

However, I'm having a hard time seeing how this is actually what you would want. But it will answer the question you've asked.

 

X = round(3.340422, 1.79);
vinod4842
Fluorite | Level 6
thanku very much reeza

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 1014 views
  • 1 like
  • 2 in conversation