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 open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.