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

 

 

Hi all 

 

I wanna to convert the variable values from normal to percentages. 

for example, I want to have 3 of 0.03 .... etc. 

 

regards 

 

Ibrahim  

1 ACCEPTED SOLUTION
8 REPLIES 8
PeterClemmensen
Tourmaline | Level 20
data _null_;
   a=0.03;
   put a;
   format a percent.;
run;
Barkamih
Pyrite | Level 9

thanks a lot, but I need just a number, I don't want a percent sign (%) to appear in my data?

regards 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Don't know how you come up with them Smiley LOL

RW9
Diamond | Level 26 RW9
Diamond | Level 26

As always, post test data in the form of a datastep, and what you want to see out at the end.  Your post says nothing.  Do you have 3 or 0.03?  You don't want percent apparently from the other posts, so what do you want, 3/100=0.03?

FreelanceReinh
Jade | Level 19

Hi @Barkamih,

 

While it may seem trivial to implement the suggestion "multiply by 100," you should remember the pitfall of numeric representation issues:

1    data _null_;
2    a=0.07;
3    a=100*a;
4    if a>7 then put 'Surprise! It looks like ' a '> 7.';
5    run;

Surprise! It looks like 7 > 7.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

So, use the ROUND function to avoid such surprises:

a=round(100*a, 1e-9);

 (in place of a=100*a; )

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 8 replies
  • 1289 views
  • 6 likes
  • 5 in conversation