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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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