Hi
I would like my format labels left aligned. How do I achieve this? In fact why aren't they left aligned already? My prefix is "Group " not " Group "...
proc format;
picture sgb 1-4='9' (prefix='Group ')
5-high='9 (mean)' (prefix='Group ')
;
run;
data test;
do i = 1, 11;
output;
end;
format i sgb.;
run;
I'm using SAS 9.4M5. Suggestions gratefully received!
Thanks in advance.
I don't think this is possible directly with a picture format. Numeric values are always right aligned, picture format or not.
I think the best choice is to use the PUT Function with the -L alignment specification like this (The -L is default, so you don't actually need it).
proc format;
picture sgb 1-4='9' (prefix='Group ')
5-high='9 (mean)' (prefix='Group ')
;
run;
data test;
do i = 1, 11;
var=put(i, sgb. -l);
output;
end;
run;
proc print data=test;
run;
This gives you
Ah ok, pity, but that basically confirms my thinking - thanks! PUT doesn't really help me as I need a numeric variable with a format attached (for testing purposes).
Use PROC REPORT to display the values.
proc report data=test;
define i / display left format=sgb.;
run;
I don't this can be done in a dataset, but, of course in a report:
proc format;
picture sgb 1-4='9' (prefix='Group ')
5-high='9 (mean)' (prefix='Group ')
;
run;
data test;
do i = 1, 11;
output;
end;
run;
proc print data=test;
var i / style(data)=[textalign=left];
format i sgb.;
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.