<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ODS Excel  - proc print columns widths in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ODS-Excel-proc-print-columns-widths/m-p/906693#M358008</link>
    <description>&lt;P&gt;I am not able to reproduce this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let length_var=8,11,14,125,8,8,8,8,8,11,125,14,14,14;
ods excel file="test.xlsx" options(flow = "header, data" absolute_column_width="&amp;amp;length_var" absolute_row_height = "20px");
proc print data=sashelp.cars noobs;
run;
ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PaigeMiller_0-1701950776166.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/90943i3FE56415872D1DE5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PaigeMiller_0-1701950776166.png" alt="PaigeMiller_0-1701950776166.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Dec 2023 12:06:22 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-12-07T12:06:22Z</dc:date>
    <item>
      <title>ODS Excel  - proc print columns widths</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-Excel-proc-print-columns-widths/m-p/906480#M357939</link>
      <description>&lt;P&gt;I need some further assistance on a solution detailed in a previous post please.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/ODS-Excel-problem-with-wrap-text/m-p/576144#M163046" target="_blank"&gt;Solved: Re: ODS Excel - problem with wrap text - SAS Support Communities&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My issue is after passing the list of length values to the macro variable, when it then applies this in the proc print via the 'absolute_column_width = "&amp;amp;length_var"' section&amp;nbsp; it's applying the first length from the macro variable to all columns, rather than being dynamic and changing for each one.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;/* creating a macro variable containing these lengths separated by a comma */
proc sql noprint ; 
select length into : length_var separated by ',' 
from other_name ; 
quit ;

/* EXPORT */

ods excel file="path\name_output.xlsx" 
options(
flow = "header, data" 
absolute_column_width = "&amp;amp;length_var" 
absolute_row_height = "20px"
);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: I am not using 'tagsets.excel' as we only have 'tagsets.excelbase' or 'tagsets.excelxp' in our current sas installation, but I don't think this is the issue anyway.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2023 15:44:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-Excel-proc-print-columns-widths/m-p/906480#M357939</guid>
      <dc:creator>sasheadache</dc:creator>
      <dc:date>2023-12-06T15:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: ODS Excel  - proc print columns widths</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-Excel-proc-print-columns-widths/m-p/906483#M357941</link>
      <description>&lt;P&gt;What is the value of the macro variable &amp;amp;length_var ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you show us the entire code instead of fragments?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You mention tagsets.excelxp but you are not using tagsets.excelxp, why? You are using ODS EXCEL, not tagsets.excelcp&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2023 15:53:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-Excel-proc-print-columns-widths/m-p/906483#M357941</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-12-06T15:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: ODS Excel  - proc print columns widths</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-Excel-proc-print-columns-widths/m-p/906485#M357942</link>
      <description>&lt;P&gt;And the values of Length in data set OTHER_NAME are what?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should be made aware that PX is not a portable unit of measure. Using such a unit becomes dependent on the display and running the code on a different system can result on unreadable text.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2023 16:02:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-Excel-proc-print-columns-widths/m-p/906485#M357942</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-12-06T16:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: ODS Excel  - proc print columns widths</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-Excel-proc-print-columns-widths/m-p/906658#M357998</link>
      <description>&lt;P&gt;The full code extract was on the original post - included now for reference.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my adapted version of this code the only difference is the fact I am using 'ods tagsets.excelbase' instead of&amp;nbsp;'ods excel' from the original post.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=""&gt;&lt;CODE&gt;/* 1) proc contents to recover the length of each variables */
proc contents data = table_you_want_export 
out = other_name (keep = varnum length) noprint ; 
run ;

/* sorting by varnum to have the same order that the table you want export */
proc sort data = other_name ; 
by varnum ; 
run ;
	
/* creating a macro variable containing these lengths separated by a comma */
proc sql noprint ; 
select length into : length_var separated by ',' 
from other_name ; 
quit ;

/* EXPORT */

ods excel file="path\name_output.xlsx" 
options(
flow = "header, data" 
absolute_column_width = "&amp;amp;length_var" 
absolute_row_height = "20px"
); 

Proc print data = table_you_want_export noobs ;
run ;

ods excel close ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The value of the macro variable resolves to:&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;DIV class=""&gt;83 %put &amp;amp;length_var.;&lt;/DIV&gt;&lt;DIV class=""&gt;SYMBOLGEN: Macro variable LENGTH_VAR resolves to 8,11,14,125,8,8,8,8,8,11,125,14,14,14&lt;/DIV&gt;&lt;DIV class=""&gt;8,11,14,125,8,8,8,8,8,11,125,14,14,14&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The first value in the macro variable is 8 and the proc print is then applying this length to all columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2023 07:24:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-Excel-proc-print-columns-widths/m-p/906658#M357998</guid>
      <dc:creator>sasheadache</dc:creator>
      <dc:date>2023-12-07T07:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: ODS Excel  - proc print columns widths</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-Excel-proc-print-columns-widths/m-p/906693#M358008</link>
      <description>&lt;P&gt;I am not able to reproduce this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let length_var=8,11,14,125,8,8,8,8,8,11,125,14,14,14;
ods excel file="test.xlsx" options(flow = "header, data" absolute_column_width="&amp;amp;length_var" absolute_row_height = "20px");
proc print data=sashelp.cars noobs;
run;
ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PaigeMiller_0-1701950776166.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/90943i3FE56415872D1DE5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PaigeMiller_0-1701950776166.png" alt="PaigeMiller_0-1701950776166.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2023 12:06:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-Excel-proc-print-columns-widths/m-p/906693#M358008</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-12-07T12:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: ODS Excel  - proc print columns widths</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-Excel-proc-print-columns-widths/m-p/906717#M358018</link>
      <description>&lt;P&gt;So I don't have the ability to simply use 'ods excel' because it produces excel files which are full of nonsense i.e. special characters &amp;amp; symbols (guessing its a SAS config issue at my company). But the good news is I have now managed to replace the same steps using my current method of output using 'ods tagsets.excelbase'.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I didn't realise until now how many different variations there were with outputting and formatting data to Excel, so that should keep me busy upskilling for a few weeks. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for taking the time to reply - all the best!&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2023 15:24:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-Excel-proc-print-columns-widths/m-p/906717#M358018</guid>
      <dc:creator>sasheadache</dc:creator>
      <dc:date>2023-12-07T15:24:50Z</dc:date>
    </item>
  </channel>
</rss>

