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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.