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
data _null_;
a=0.03;
put a;
format a percent.;
run;
Use the percent. format:
data want;
x1 = .03;
format x1 percent6.;
run;
thanks a lot, but I need just a number, I don't want a percent sign (%) to appear in my data?
regards
Then multiply by 100?
Proud of this one 🙂
Don't know how you come up with them
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?
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; )
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.