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
Super User

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
PROC Star

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

Innovate_SAS_Blue.png

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. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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