Hi,
I need a user defined format and I never used PROC Format before and I am a bit lost here.
I need a format like this:
Input Value: 0.571
Output Value: +/+ 57,1%
Input Value: -1.3
Output Value: -/- 130%
This is what I got so far:
Data numbers;
input values;
cards;
0.1119
0.2119
0.57119
-0.5134
2
40
-5
;
run;
proc format;
picture advperc
low -< 0 = '99.99 %' (prefix='-/- ' mult=10000)
0 - high = '99.99 %' (prefix='+/+ ' mult=10000);
run;
proc print data = numbers;
format values advperc.;
run;
I m not quite there yet. The last 3 lines are not right.
Thank you in advance
Dirk
Data numbers;
input values;
cards;
0.1119
0.2119
0.57119
-0.5134
2
40
-5
;
run;
proc format;
picture advperc
low - -1 = '00000 %' (prefix='+/+ ' mult=10000)
-1< -< 0 = '00.00 %' (prefix='-/- ' mult=10000)
0 - < 1 = '00.00 %' (prefix='+/+ ' mult=10000)
1 - high = '00000 %' (prefix='+/+ ' mult=10000);
run;
proc print data = numbers;
format values advperc.;
run;
Data numbers;
input values;
cards;
0.1119
0.2119
0.57119
-0.5134
2
40
-5
;
run;
proc format;
picture advperc
low - -1 = '00000 %' (prefix='+/+ ' mult=10000)
-1< -< 0 = '00.00 %' (prefix='-/- ' mult=10000)
0 - < 1 = '00.00 %' (prefix='+/+ ' mult=10000)
1 - high = '00000 %' (prefix='+/+ ' mult=10000);
run;
proc print data = numbers;
format values advperc.;
run;
Thank you!
I had to add another 0 and it is working now:
1 - high = '000000 %' (prefix='+/+ ' mult=10000);
Best regards
Dirk
Add more 0s.
Data numbers;
input values;
cards;
0.1119
0.2119
0.57119
-0.5134
2
40
-5
;
run;
proc format;
picture advperc
low - -1 = '0000000 %' (prefix='-/- ' mult=10000)
-1< -< 0 = '00.00 %' (prefix='-/- ' mult=10000)
0 - < 1 = '00.00 %' (prefix='+/+ ' mult=10000)
1 - high = '0000000 %' (prefix='+/+ ' mult=10000);
run;
proc print data = numbers;
format values advperc.;
run;
Actually this could be more simple.
Data numbers;
input values;
cards;
0.1119
0.2119
0.57119
-0.5134
2
40
-5
;
run;
proc format;
picture advperc
low -< 0 = '0000000000.00 %' (prefix='-/- ' mult=10000)
0 - < high = '0000000000.00 %' (prefix='+/+ ' mult=10000) ;
run;
proc print data = numbers;
format values advperc.;
run;
I don't understand.
200=2*100 ,whereas 40000=40*1000
I ve got this working now.
Data numbers;
input values;
cards;
0.1119
0.2119
0.57119
-0.5134
2
40
-5
;
run;
proc format;
picture advperc
low -< 0 = '0000.99 %' (prefix='-/- ' mult=10000)
0 - high = '0000.99 %' (prefix='+/+ ' mult=10000);
run;
proc print data = numbers;
format values advperc.;
run;
I had a typo,
2 = 200, 40 = 4000
Your first output gave me
SAS Output
+/+ 11.19 % |
+/+ 21.19 % |
+/+ 57.11 % |
-/- 51.34 % |
+/+ 20000 % |
+/+ 400000 % |
-/- 50000 % |
I think you should multiply 100 not 10000.
Data numbers;
input values;
cards;
0.1119
0.2119
0.57119
-0.5134
2
40
-5
;
run;
proc format;
picture advperc
low -< 0 = '0000000000.99 %' (prefix='-/- ' mult=100)
0 - < high = '0000000000.99 %' (prefix='+/+ ' mult=100) ;
run;
proc print data = numbers;
format values advperc.;
run;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.