Can someone suggest a fix that will make the "<0.5%" format work?
proc format; picture custpcttwo /*format values above .5% as whole percentages*/ .005-high='0009%' (round) (mult=100) /*for those btw 0 and .5% format as "<0.5%"*/ low-<.005 = '<0.5%' ; run; data a; x=.005; y=.0003; run; proc print data=a; var x y; format x y custpcttwo.; run;
Yes, as long as you move the round picture option to right after the picture format name.
...
picture custpcttwo (round)
...
edited to include complete solution:
You'll want to add a (noedit) picture option after the '<0.5%' since you're not using digit selectors.
proc format; picture custpcttwo /*format values above .5% as whole percentages*/ .005-high='0009%' (round) (mult=100) /*for those btw 0 and .5% format as "<0.5%"*/ low-<.005 = '<0.5%' (noedit) ; run;
I ran the following code:
proc format ;
picture custpcttwo (round)
/*format values above .5% as whole percentages*/
.005-high='0009%' (mult=100)
/*for those btw 0 and .5% format as "<0.5%"*/
low-<.005 = '<0.5%' (noedit)
;
run;
data a;
x=.005;
y=.0003;
run;
proc print data=a;
var x y;
format x y custpcttwo.;
run;
and got:
![]()
Hi @Batman, you'll want to add a (noedit) picture option after the '<0.5%' since you're not using digit selectors.
proc format; picture custpcttwo /*format values above .5% as whole percentages*/ .005-high='0009%' (round) (mult=100) /*for those btw 0 and .5% format as "<0.5%"*/ low-<.005 = '<0.5%' (noedit) ; run;
Where you able to get it to work when you ran it? For me, the formatted value of "y" is still "0%"
Yes, I ran the following code:
proc format;
picture custpcttwo
/*format values above .5% as whole percentages*/
.005-high='0009%' (mult=100)
/*for those btw 0 and .5% format as "<0.5%"*/
low-<.005 = '<0.5%' (noedit)
;
run;
data a;
x=.005;
y=.0003;
run;
proc print data=a;
var x y;
format x y custpcttwo.;
run;
and got:
I should mention that you also have to move the round picture option since it applies to all values:
proc format;
picture custpcttwo (round)
/*format values above .5% as whole percentages*/
.005-high='0009%' (mult=100)
/*for those btw 0 and .5% format as "<0.5%"*/
low-<.005 = '<0.5%' (noedit)
;
run;
Sorry I forgot to mention, I'd still like to be able to round the value of "x", so it should be 1%. Is that doable?
Yes, as long as you move the round picture option to right after the picture format name.
...
picture custpcttwo (round)
...
edited to include complete solution:
You'll want to add a (noedit) picture option after the '<0.5%' since you're not using digit selectors.
proc format; picture custpcttwo /*format values above .5% as whole percentages*/ .005-high='0009%' (round) (mult=100) /*for those btw 0 and .5% format as "<0.5%"*/ low-<.005 = '<0.5%' (noedit) ; run;
I ran the following code:
proc format ;
picture custpcttwo (round)
/*format values above .5% as whole percentages*/
.005-high='0009%' (mult=100)
/*for those btw 0 and .5% format as "<0.5%"*/
low-<.005 = '<0.5%' (noedit)
;
run;
data a;
x=.005;
y=.0003;
run;
proc print data=a;
var x y;
format x y custpcttwo.;
run;
and got:
![]()
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.