BookmarkSubscribeRSS Feed
rhale
Fluorite | Level 6

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.

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

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

 

Capture.PNG 

rhale
Fluorite | Level 6

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).

Tom
Super User Tom
Super User

Use PROC REPORT to display the values.

proc report data=test;
 define i / display left format=sgb.;
run;

image.png

andreas_lds
Jade | Level 19

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;

SAS Innovate 2025: Register Now

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!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1342 views
  • 2 likes
  • 4 in conversation