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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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