I ran the following code and end up with error as follows. Could you please help me with the format which translate comma values to percent? I don't wish to do any data manipulation here.
data foo;
format y percent7.1;
y=-0,01259870;
run;
proc print data=foo;
run;
Log:
26 data foo;
27 format y percent7.1;
28 y=-0,01259870;
_
388
200
ERROR 388-185: Expecting an arithmetic operator.
ERROR 200-322: The symbol is not recognized and will be ignored.
Desired output:
1.3%
You cannot write code using that non-standard method of using commas to replace decimal points.
But you can use the COMMAX informat to read strings that are written that way.
data test ;
input @1 string $12. @1 number commax12. ;
percent=number;
format percent percent7.1 ;
put (_all_) (=/);
cards;
-0,01259870
;
string=-0,01259870 number=-0.0125987 percent=( 1.3%)
No, I no need to convert comma to dot. I have values in my file like -0,01259870
then please something as below
data foo;
format y percent7.1;
y=input(tranwrd('-0,01259870',',','.'),best.);
run;
proc print data=foo;
run;
You cannot write code using that non-standard method of using commas to replace decimal points.
But you can use the COMMAX informat to read strings that are written that way.
data test ;
input @1 string $12. @1 number commax12. ;
percent=number;
format percent percent7.1 ;
put (_all_) (=/);
cards;
-0,01259870
;
string=-0,01259870 number=-0.0125987 percent=( 1.3%)
Or
data test ; input number numx12. ; format number percent15.5 ; cards; -0,01259870 ; run;
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!
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.