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

Hi,

I'm trying to convert numbers such as 32.5 to 32,5% using a format. 

 

Below is the link to the format which adds the % symbol but I can't seem to find one which converts it to European decimal convention as well. 

https://support.sas.com/kb/38/001.html

 

 

Thanks,

Mladen

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

I don't think such a format exists. though you can roll out your own doing something like this

 


proc format;
   picture fmt other = '09,9%' (mult=10);
run;

data test;
   a = 32.5;
   format a fmt.;
run;

View solution in original post

7 REPLIES 7
PeterClemmensen
Tourmaline | Level 20

I don't think such a format exists. though you can roll out your own doing something like this

 


proc format;
   picture fmt other = '09,9%' (mult=10);
run;

data test;
   a = 32.5;
   format a fmt.;
run;
Cannon3006
Calcite | Level 5

Thanks that's exactly what I was looking for. 

Ksharp
Super User

Draycut,

What if there are two or more digit after decimal ?

 

proc format;
   picture fmt other = '09,99%' (decsep=',');
run;

data test;
   a = 32.5;output;
   a = 32.55;output;
   format a fmt.;
run;
Cannon3006
Calcite | Level 5

This worked great for me also. Is it possible to combine decsep and mult, to convert 0.325 to 32,5%. The code below did not work. 

 

proc format;
   picture fmt other = '09,99%' (decsep=',' mult=100);
run;

However I did get it working using the method from the answer, I just wanted to know why mult and decsep did not work together.

proc format;
   picture fmt other = '009,99%' (mult=10000);
run;

 

 

Ksharp
Super User

You want this ?

 

proc format;
   picture fmt other = '09,99%' (decsep=',' multi=10000 );
run;

data test;
   a = .325;output;
   a = .326;output;
   format a fmt.;
run;
Cannon3006
Calcite | Level 5
Yes, but that format works even without decsep=',' .The decsep seems to only work without the multiplication option. I was just curious why.
Ksharp
Super User
No. That is different .
if without decsep=',' then
a = .325 multiply 10000 --> 3250 and insert comma at the last two position. --> 32,50

if with decsep=',' then
a = .325; --> .00325 (due to '09,99' with decsep=',') and multiply 10000. --> 32.5
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
  • 7 replies
  • 1813 views
  • 0 likes
  • 3 in conversation