Learning SAS? Welcome to the exclusive online community for all SAS learners.

proc print with uniform option

Reply
Contributor
Posts: 22

proc print with uniform option

How do I get all columns aligned across by groups?  here is my code:

proc print width=uniform;

    format city $25. pop2013 comma12.;

    by state;

    id city;

The length of "city" changes whenever the by group changes;  I also tried uniformby and got the same results.;  Running SAS studio under SODA.

PS I wanted to attach a PDF showing my output, but this system doesn't allow PDF or DOCX attachment.  Is there a way for me to share proc print output?

Super User
Posts: 10,552

Re: proc print with uniform option

ID city /style=[cellwidth=3cm] ; assigns a fixed width for the variable of 3cm. Pick a number, decimals are accepted, and a measurement unit such as cm, in or others.

Contributor
Posts: 22

Re: proc print with uniform option

Thank, that worked.

But I'd still like to know why the "uniform" option didn't work.  It would be more convenient if SAS would figure out the column width for me.  Is there something wrong with my code or is this a bug in SAS?  I used "uniform" frequently in my SAS 8 / z/OS days and never had this problem.

Super User
Posts: 10,552

Re: proc print with uniform option

If you use variables with explicit lengths on the variables such as $25. and Comma12. you might try the option with Width=Full.

I suspect some of the issues come with algorithms that have to deal with what to do with the requested length of line would exceed the target destination display capability such as the print statement wanting to use 12 inches of an 8-inch wide PDF document.

There is also the interaction with column headings that can interfere with Width options.

SAS Super FREQ
Posts: 8,745

Re: proc print with uniform option


Hi:

  The UNIFORM option will work differently in different destinations and for some destinations, can be impacted by your margin and other settings. Since you did not show all your code, I showed my preferred approach, which is the style override approach. I like to use it because in my experience, UNIFORM was originally designed for the LISTING destination, which isn't used really in SAS Studio, so I prefer to use the style method. In addition, as it explains in the documentation, PROC PRINT with the UNIFORM option has to read through ALL the observations at least 1 time to determine the maximum width -- for the LISTING window. So, why not save the overhead and set the size in the style override. Plus, as it explains here, 24237 - Where does the UNIFORM option make a difference in ODS PRINTER? if you are using UNIFORM with BY group processing, then you only get uniformity within each BY group, not BETWEEN different by groups.  Here's the code I ran (you will notice I got rid of WIDTH and HEADLINE, since they are ignored by ODS destinations):

data newshoes;

  set sashelp.shoes;

  where region in ('Asia', 'Canada');

  if region = 'Canada' then region = catt(region,'ABCDEFGHIJKLMNO');

run;

  

proc sort data=newshoes; by region; run;

  

ods pdf file='/home/username/output/uniform_test.pdf';

ods html file='/home/username/output/uniform_test.html';

ods rtf file='/home/username/output/uniform_test.rtf';

proc print data=newshoes ;

  by region;

  pageby region;

  var region / style(data)={width=3in};

  var sales inventory returns /style(data)={width=1in};

run;

 

ods _all_ close;

Results using SAS Studio on the SODA server are below.

cynthia

HTML:

uniform_html.png

RTF:

uniform_rtf.png

PDF:

uniform_pdf.png

(you can paste screen shot/images using the little camera icon up on the editing tool bar. I tested the code in SAS Display Manager on Windows and on the SAS OnDemand server using SAS Studio. Results were the same.)

soda_code_style_overrides.png

Contributor
Posts: 22

Re: proc print with uniform option

Thanks, Cynthia

Contributor
Posts: 22

Re: proc print with uniform option

I tired "width=full" and removing the style parameter, but it didn't work.  I got the same results as I got with "uniform" and "uniformby".  The print  line contains only two variables so the total number of print columns is 37.  I'm not using labels, so the first column heading is 4 characters and the second is 7.

Ask a Question
Discussion stats
  • 6 replies
  • 811 views
  • 4 likes
  • 3 in conversation