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

HI,

 

I have a value x=0.032949.

 

if x >= 0.0001 then y=put(round(x,0.0001),7.4);

 

I am getting x=0.017.

 

Where as I should be getting 0.0329.

 

Why is this happening?

How do I fix this?

 

Thanks,

Archana

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Post your full code and the log.

I suspect something is going on with your y variable as I can't reproduce your error with this program:

data junk;
x=0.032949;
if x >= 0.0001 then y=put(round(x,0.0001),7.4);
run;

I get the expected value.

 

 

And your reason for not using y=put(x,7.4); is exactly what?

View solution in original post

3 REPLIES 3
Haikuo
Onyx | Level 15

SAS version? OS?

I couldn't repeat your issue.

 

23         data _null_ ;
24         x=0.032949;
25         y=put(round(x,0.0001),7.4);
26         put y=;
27         run;

y=0.0329
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
stat_sas
Ammonite | Level 13

Following syntax is giving right numbers. Look for Y variable instead of X for rounded numbers

 

data _null_;
x=0.032949;
if x >= 0.0001 then y=put(round(x,0.0001),7.4);
put _all_;
run;

ballardw
Super User

Post your full code and the log.

I suspect something is going on with your y variable as I can't reproduce your error with this program:

data junk;
x=0.032949;
if x >= 0.0001 then y=put(round(x,0.0001),7.4);
run;

I get the expected value.

 

 

And your reason for not using y=put(x,7.4); is exactly what?

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3 replies
  • 1013 views
  • 0 likes
  • 4 in conversation