BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Nico
Calcite | Level 5

I am using the List Data task to output some data over several pages using a by variable. I would be nice to have the same column width for the different pages in the report.

SAS EG appears to have an option to control the column width (e.g., based on formats or maximum width of the data in the column). However, it does not appear to do anything. How can I make this option work?

Regards, Nico


List Data task.PNG
1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  The window that you show is, behind the scenes, controlling the WIDTH= option that goes on the PROC PRINT statement. (PROC PRINT is underneath the LIST DATA task.) Some of the possible options (like FULL and MINIMUM) were only intended to work in the LISTING (text) destination. So, you show MINIMUM as being checked and this will not work for the default SASReport format or HTML, RTF or PDF result types.

  

  As a result of investigating your question, we have discovered that the UNIFORM choice for option setting does not appear to work as you would expect in ODS destinations. So, if you needed to have all the cells for a particular value be the same width (the equivalent of using UNIFORM), there is a way using ODS STYLE= overrides for RTF, PDF and HTML to specify a column width that will be used for all values, no matter what the internal number of characters for the variable value is, but this does require using code or altering the code generated by the List Data task.

  For example, in this code example below, the variable REGION will have a column width that is bigger than the width used for SALES, INVENTORY and RETURNS. With paged destinations, like PDF, and RTF, you have to be sure that the width of all your columns, when added together, does not exceed the printable area on the page or else you will get undesirable "splitting" of the columns. With HTML (and probably SASReport), you do not have to worry about the width of the final report because the HTML file can be as wide as it needs to be.

  Anyway, in this example, you should see that the page for Asia has the same width for REGION as the page for Western Europe when you run the code from an EG code node or new program window. I'd recommend that you go to Tools --> Options --> Results to generate SASReport, HTML and PDF or RTF to see which output you like the best.

 

cynthia

** I did not put any ODS statements around this code because if you submit from an EG code or program window;

** the ODS statements will be added, based on the result type you pick for your EG session.;

** REGION column width should be the same across all pages and for all values of REGION.;

         

proc print data=sashelp.shoes noobs;
  where region in ('Asia','Western Europe', 'Eastern Europe', 'Canada');
  by region;
  pageby region;
  var region /
      style(data)={width=2.25in};
  var product sales inventory /
      style(data)={width=1.25in};
run;

View solution in original post

3 REPLIES 3
Cynthia_sas
SAS Super FREQ

Hi:

  The window that you show is, behind the scenes, controlling the WIDTH= option that goes on the PROC PRINT statement. (PROC PRINT is underneath the LIST DATA task.) Some of the possible options (like FULL and MINIMUM) were only intended to work in the LISTING (text) destination. So, you show MINIMUM as being checked and this will not work for the default SASReport format or HTML, RTF or PDF result types.

  

  As a result of investigating your question, we have discovered that the UNIFORM choice for option setting does not appear to work as you would expect in ODS destinations. So, if you needed to have all the cells for a particular value be the same width (the equivalent of using UNIFORM), there is a way using ODS STYLE= overrides for RTF, PDF and HTML to specify a column width that will be used for all values, no matter what the internal number of characters for the variable value is, but this does require using code or altering the code generated by the List Data task.

  For example, in this code example below, the variable REGION will have a column width that is bigger than the width used for SALES, INVENTORY and RETURNS. With paged destinations, like PDF, and RTF, you have to be sure that the width of all your columns, when added together, does not exceed the printable area on the page or else you will get undesirable "splitting" of the columns. With HTML (and probably SASReport), you do not have to worry about the width of the final report because the HTML file can be as wide as it needs to be.

  Anyway, in this example, you should see that the page for Asia has the same width for REGION as the page for Western Europe when you run the code from an EG code node or new program window. I'd recommend that you go to Tools --> Options --> Results to generate SASReport, HTML and PDF or RTF to see which output you like the best.

 

cynthia

** I did not put any ODS statements around this code because if you submit from an EG code or program window;

** the ODS statements will be added, based on the result type you pick for your EG session.;

** REGION column width should be the same across all pages and for all values of REGION.;

         

proc print data=sashelp.shoes noobs;
  where region in ('Asia','Western Europe', 'Eastern Europe', 'Canada');
  by region;
  pageby region;
  var region /
      style(data)={width=2.25in};
  var product sales inventory /
      style(data)={width=1.25in};
run;

Nico
Calcite | Level 5

Hi Cynthia,

Thanks for the answer. Now I understand why the options does not work as I had expected.

The solution you present does indeed work, although I had to use 'cellwidth'  instead of 'width', but maybe that is because I am using EG 4.1

Regards, Nico

Cynthia_sas
SAS Super FREQ

Hi:

  Yes, you are correct. CELLWIDTH was the original name for that style attribute. In SAS 9.2 and 9.3, CELLWIDTH and WIDTH are interchangeable, but if you are using EG 4.1, then you are probably using SAS 9.1 and so you would need to use CELLWIDTH.

cynthia

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 1832 views
  • 0 likes
  • 2 in conversation