<?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: PROC Report &amp;amp; ODS excel: define columnwidth in function of #byval in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-Report-amp-ODS-excel-define-columnwidth-in-function-of/m-p/881305#M82801</link>
    <description>&lt;P&gt;Thank you very much &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; , &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt; for both of your solutions.&lt;/P&gt;
&lt;P&gt;I've tried the code and it does exactly what I want.&lt;/P&gt;
&lt;P&gt;Also thank you to all other members who contributed.&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>Sun, 18 Jun 2023 10:07:20 GMT</pubDate>
    <dc:creator>fre</dc:creator>
    <dc:date>2023-06-18T10:07:20Z</dc:date>
    <item>
      <title>PROC Report &amp; ODS excel: define columnwidth in function of #byval</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-Report-amp-ODS-excel-define-columnwidth-in-function-of/m-p/881113#M82793</link>
      <description>&lt;DIV&gt;Dear community,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;I'm learning the very interesting proc report with ODS excel.&lt;/DIV&gt;
&lt;DIV&gt;Currently, I have a layout-issue I can't figure out and which Google can't help me.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;I want to define the columnwidth of a variable in function of the sheet.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;I've managed to create a multi-sheet excelfile, where each sheet has a sheetname based on the value of #byval1.&lt;/DIV&gt;
&lt;DIV&gt;#byval1 can have 3 values:&amp;nbsp; X, Y and Z - so the name of the 3 sheets are respectively X, Y and Z.&lt;/DIV&gt;
&lt;DIV&gt;What I want:&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;if #byval1 = X then columnwidth of varB is 20&amp;nbsp; (this is sheet 'X')&lt;/DIV&gt;
&lt;DIV&gt;if #byval1 = Y then columnwidth of varB is 40&amp;nbsp; (this is sheet 'Y')&lt;/DIV&gt;
&lt;DIV&gt;if #byval1 = Z then columnwidth of varB is 60&amp;nbsp; (this is sheet 'Z)&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;This is my current code:&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro make_excel;

ods excel&amp;nbsp;
file=outfile2&amp;nbsp;
options(sheet_name = "#byval1");

proc report&amp;nbsp;
data=base&amp;nbsp;
nowd&amp;nbsp;
out=abc
by varA;

column varA varB varC;

define varA / order ;
define varB / order style(column)=[width=65mm] ;
define varC / display;
run;

ODS EXCEL CLOSE;

%mend;

%make_excel&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;I've tried to replace the code for "define varB" with the following lines:&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
define varB / order
%if #byval1='X' %then %do; style(column)=[width=20mm]&amp;nbsp; %end;
%if #byval1='Y' %then %do; style(column)=[width=40mm]&amp;nbsp; %end;
%if #byval1='Z' %then %do; style(column)=[width=60mm]&amp;nbsp; %end;
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;DIV&gt;but that doesn't do the job, it gives errors.&lt;/DIV&gt;
&lt;DIV&gt;Is the approach I'm trying to use the correct one ?&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;What am I missing here?&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Any help much appreciated&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Fri, 16 Jun 2023 14:55:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-Report-amp-ODS-excel-define-columnwidth-in-function-of/m-p/881113#M82793</guid>
      <dc:creator>fre</dc:creator>
      <dc:date>2023-06-16T14:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: PROC Report &amp; ODS excel: define columnwidth in function of #byval</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-Report-amp-ODS-excel-define-columnwidth-in-function-of/m-p/881158#M82795</link>
      <description>&lt;P&gt;First "Why?". If you use SHEET_INTERVAL='BYGROUP' then each table of the Proc Report output should be written to a separate sheet and if the length of variables changes then the sizing might be automatic. Can't test without data though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may also need some more options as if your longer values have spaces in them the text may want to wrap in the cell regardless of cell width.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only approach that comes to mind where this might work would be make separate calls to Proc Report filtering data at each call to that specific value using macro code to add in the conditional width.&lt;/P&gt;
&lt;P&gt;That would not using BY processing so BYVAL wouldn't be available anywhere and would be using Where Vara="&amp;amp;somemacrovariable" where that macro variable holds the value to make the table. You would also have statements in the body of the proc report like&lt;/P&gt;
&lt;PRE&gt;%if &amp;amp;somemacrovariable=X %then %do;
        define varB / order style(column)=[width=20mm] ;
%end;
%if &amp;amp;somemacrovariable=Y %then %do;
        define varB / order style(column)=[width=40mm] ;
%end;
%if &amp;amp;somemacrovariable=Z %then %do;
        define varB / order style(column)=[width=60mm] ;
%end;&lt;/PRE&gt;
&lt;P&gt;This would require providing lists of values for the macro variable in some manner.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Calling &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt; to see if she as more insight into possible approaches.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2023 17:50:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-Report-amp-ODS-excel-define-columnwidth-in-function-of/m-p/881158#M82795</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-06-16T17:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: PROC Report &amp; ODS excel: define columnwidth in function of #byval</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-Report-amp-ODS-excel-define-columnwidth-in-function-of/m-p/881223#M82796</link>
      <description>&lt;P&gt;Thank you for your reply.&lt;/P&gt;
&lt;P&gt;Why?&amp;nbsp;&amp;nbsp; Because there are indeed cases where the values are longer (with spaces) and proc report with ods excel automatically wraps these values, which I don't want to.&lt;/P&gt;
&lt;P&gt;The only way I can prevent this, is to define a specific length for each byval ( or sheet) in the define of varB.&lt;/P&gt;
&lt;P&gt;That's why I think I need to pass through the value of the byval to a macro-variable but I'm not sure how...&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2023 20:08:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-Report-amp-ODS-excel-define-columnwidth-in-function-of/m-p/881223#M82796</guid>
      <dc:creator>fre</dc:creator>
      <dc:date>2023-06-16T20:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: PROC Report &amp; ODS excel: define columnwidth in function of #byval</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-Report-amp-ODS-excel-define-columnwidth-in-function-of/m-p/881227#M82797</link>
      <description>&lt;P&gt;Sounds like you need the FLOW option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="xis-eDocBody"&gt;
&lt;DIV class="xis-refDictEntry"&gt;
&lt;DIV class="xis-syntax"&gt;
&lt;DIV class="xis-syntaxDescription"&gt;
&lt;DIV class="xis-optionalArgGroup"&gt;
&lt;DIV id="p0258wnlz15ubrn1vqfalp6l4hjz" class="xis-argDescriptionPair"&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;DIV id="n0bzak0fefbrq6n19j1e1dlsqmo5" class="xis-argDescriptionPair"&gt;
&lt;H4 class="xis-argument"&gt;FLOW=&lt;SPAN class="xis-argOption"&gt;&amp;lt;&lt;SPAN class="xis-userSuppliedValue"&gt;"cell-names"&lt;/SPAN&gt;, "DATA", "HEADERS", "ROWHEADERS", "TABLES", "TEXT" &amp;gt;&lt;/SPAN&gt;&lt;/H4&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;P class="xis-paraSimpleFirst"&gt;specifies that a designated Worksheet&lt;FONT color="#FF0000"&gt; area enables Wrap Text and disables newline character insertion&lt;/FONT&gt;. &lt;FONT&gt;Excel&lt;/FONT&gt; wraps the text to the column width.&lt;/P&gt;
&lt;DIV id="p0pyl0o4t3vp6nn1ag9a79r8cuco" class="xis-argDescriptionPair"&gt;
&lt;H4 class="xis-argument"&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;cell-names&lt;/SPAN&gt;&lt;/H4&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;P class="xis-paraSimpleFirst"&gt;enables Wrap Text for a single cell such as “A12” or a cell range such as “C1:E4”.&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV id="p07jdwsmmkqzoin1kvf3lsumddjd" class="xis-argDescriptionPair"&gt;
&lt;H4 class="xis-argument"&gt;DATA&lt;/H4&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;P class="xis-paraSimpleFirst"&gt;enables Wrap Text for table data cells.&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV id="p0hnicsn3ahqwtn1lu0fmkm3brfn" class="xis-argDescriptionPair"&gt;
&lt;H4 class="xis-argument"&gt;HEADERS&lt;/H4&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;P class="xis-paraSimpleFirst"&gt;enables Wrap Text in table column headers.&lt;/P&gt;
&lt;TABLE class="xis-summary"&gt;&lt;!-- alias template --&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="xis-alias"&gt;Alias&lt;/TD&gt;
&lt;TD class="xis-summaryText"&gt;HEADER&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV id="n15i31pnrv4jc6n1pj7akn8sd6a4" class="xis-argDescriptionPair"&gt;
&lt;H4 class="xis-argument"&gt;ROWHEADERS&lt;/H4&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;P class="xis-paraSimpleFirst"&gt;enables Wrap Text for table row headers.&lt;/P&gt;
&lt;TABLE class="xis-summary"&gt;&lt;!-- alias template --&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="xis-alias"&gt;Alias&lt;/TD&gt;
&lt;TD class="xis-summaryText"&gt;ROWHEADER&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV id="n00o96o2khs8tbn13ubo9bpo8vb0" class="xis-argDescriptionPair"&gt;
&lt;H4 class="xis-argument"&gt;TABLES&lt;/H4&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;P class="xis-paraSimpleFirst"&gt;enables Wrap Text for all parts of a table: HEADER, ROWHEADER, and DATA.&lt;/P&gt;
&lt;TABLE class="xis-summary"&gt;&lt;!-- alias template --&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="xis-alias"&gt;Alias&lt;/TD&gt;
&lt;TD class="xis-summaryText"&gt;TABLE&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV id="n04lkesl7nvjlfn1pmddvrh3pjxv" class="xis-argDescriptionPair"&gt;
&lt;H4 class="xis-argument"&gt;TEXT&lt;/H4&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;P class="xis-paraSimpleFirst"&gt;makes &lt;FONT&gt;ODS&lt;/FONT&gt; TEXT output work like titles, footnotes, PROC titles, and BY lines. The text is written into multiple merged cells and Wrap Text is enabled.&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 16 Jun 2023 21:13:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-Report-amp-ODS-excel-define-columnwidth-in-function-of/m-p/881227#M82797</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2023-06-16T21:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: PROC Report &amp; ODS excel: define columnwidth in function of #byval</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-Report-amp-ODS-excel-define-columnwidth-in-function-of/m-p/881258#M82798</link>
      <description>&lt;P&gt;HI:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; One of the challenges in what you're trying to do is that you can't test #byval in code. It's not a macro variable. It is designed to be used in a TITLE statement and does not "exist" in a place where you can test it in a PDV or in the REPORT procedure. There may be some way around it, but not using #BYVAL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; But the other thing I find confusing is that VARB in an single dataset is going to have only one length, internally stored, in the descriptor portion of the data. Let's say that the internally stored length for VARB is 40.&amp;nbsp; So, if I understand what is described, it sounds like for one BY group, the actual max length of VARB could be 20, but for another BY group, the actual max length of VARB could be 5, and then for another BY group, the actual max length of VARB could be 30. What is wanted is NOT displaying the cell on each sheet with the maximum length, what is needed/wanted is a way to control the width for VARB based on the value of the BY variable. Is that correct????&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jun 2023 14:15:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-Report-amp-ODS-excel-define-columnwidth-in-function-of/m-p/881258#M82798</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2023-06-17T14:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: PROC Report &amp; ODS excel: define columnwidth in function of #byval</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-Report-amp-ODS-excel-define-columnwidth-in-function-of/m-p/881263#M82799</link>
      <description>&lt;P&gt;Since you want to use the value of BY var as the sheet name you could just generate separate PROC steps for each by value.&amp;nbsp; So if you have a driver table with the by values and the widths you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data groups;
  input width value $50. ;
cards;
20 X
40 Y
60 Z
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then use that to generate the PROC REPORT statements.&lt;/P&gt;
&lt;P&gt;So perhaps you could setup a macro that does that and takes the width and value as input.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro bywidth(width,value);
ods excel options(sheet_name = &amp;amp;value);
proc report data=base nowd ;
  where varA = &amp;amp;value;
  column varA varB varC;
  define varA / order ;
  define varB / order style(column)=[width=&amp;amp;width.mm] ;
  define varC / display;
run;
%mend bywidth;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then use the dataset to generate the calls to the macro.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods excel file=outfile2 ;

data _null_;
  set groups;
  call execute(catx(' ','%nrstr(bywidth)(',width,',',quote(trim(value),"'"),');'));
run;

ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jun 2023 14:32:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-Report-amp-ODS-excel-define-columnwidth-in-function-of/m-p/881263#M82799</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-17T14:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: PROC Report &amp; ODS excel: define columnwidth in function of #byval</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-Report-amp-ODS-excel-define-columnwidth-in-function-of/m-p/881267#M82800</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;, that's a good approach. Another alternative is to have a user-defined format and then to use the BY variable in a BY statement AND in the COLUMN statement. That makes the value of the BY variable available to be used inside the PROC REPORT step. For this example, I created a fake VARB variable where the length changed for each value of the BY variable (I just took SASHELP.CLASS and created VARB by concatenating some fake string with NAME to give me variable lengths for each BY group:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1687013415644.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85122iFE3D9393FE5292E3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1687013415644.png" alt="Cynthia_sas_0-1687013415644.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Note that in my case, AGE is an ORDER item. That means AGE is only put on the report on the first row of the group. So I make a temporary variable HOLDAGE, that will only get changed at the start of each BY group/ORDER group (which are the same).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Then I can make a style variable SVAR which can then be used as the style string I need for the CALL DEFINE for VARB. With the PUT function, I can make the style override use my FORMAT value for the WIDTH attribute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; In this case, I only need one PROC REPORT step, I do need to have sorted data to use the BY statement and there is a bit of fiddling with temporary variables and COMPUTE blocks.&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jun 2023 14:55:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-Report-amp-ODS-excel-define-columnwidth-in-function-of/m-p/881267#M82800</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2023-06-17T14:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: PROC Report &amp; ODS excel: define columnwidth in function of #byval</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-Report-amp-ODS-excel-define-columnwidth-in-function-of/m-p/881305#M82801</link>
      <description>&lt;P&gt;Thank you very much &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; , &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt; for both of your solutions.&lt;/P&gt;
&lt;P&gt;I've tried the code and it does exactly what I want.&lt;/P&gt;
&lt;P&gt;Also thank you to all other members who contributed.&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>Sun, 18 Jun 2023 10:07:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-Report-amp-ODS-excel-define-columnwidth-in-function-of/m-p/881305#M82801</guid>
      <dc:creator>fre</dc:creator>
      <dc:date>2023-06-18T10:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: PROC Report &amp; ODS excel: define columnwidth in function of #byval</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-Report-amp-ODS-excel-define-columnwidth-in-function-of/m-p/881534#M82803</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;as I said in my previous answer, your solution does give the desired output.&lt;/P&gt;
&lt;P&gt;However, when I run your code, the log keeps firing errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the complete code:&amp;nbsp;&amp;nbsp;( &amp;amp;link_shared_folder had&amp;nbsp;been&amp;nbsp;defined&amp;nbsp;outside&amp;nbsp;this&amp;nbsp;code)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fakedata;
  set sashelp.class;
  varb = catx(" ",name,age);
run;

proc sort data=fakedata;
  by age;
run;

proc format;
  value w_by  
   11="1.25in"
   12="1.25in"
			13="2.0in"
			14="3.0in"
			15="1.25in"
			16="1.25in"
			;
run;

options nobyline;

%let path=&amp;amp;link_shared_folder\SAS\ODS\;
ods excel file="&amp;amp;path\diff_width.xlsx"

options (sheet_name='Age #byval1');

proc report data=fakedata out=a123;
 by age;
 column age varb sex height weight;
 define age /order page;
 define varb / display ;
 define sex / display;
 define height / display;
 define weight / display;&lt;BR /&gt;
 compute before age;
	holdage = age;
 endcomp;
&lt;BR /&gt; compute before _page_ /style=SystemTitle;
  line 'THIS BYGROUP is for Age: ' Age 2.0;
 endcomp;&lt;BR /&gt;
 compute varb;
  length svar $50;
	svar = catt ('style={width=',put (holdage,w_by.),'}');
	call define (_col_,'style',svar);
 endcomp;
&lt;BR /&gt;run;
ods excel close;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As I already said, the resulting excel-file is what I want, but in the log, I keep having these errors.&lt;/P&gt;
&lt;P&gt;I've tried to understand what the cause is, but I can't find the reason.&lt;/P&gt;
&lt;P&gt;The same error is repeated for each by-group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have any idea what's the culprit here?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1                                                          The SAS System                               13:35 Tuesday, June 20, 2023

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='Program';
4          %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5          %LET _CLIENTPROJECTPATH='xxxx';
6          %LET _CLIENTPROJECTPATHHOST='xxxx';
7          %LET _CLIENTPROJECTNAME='xxxx.egp';
8          %LET _SASPROGRAMFILE='';
9          %LET _SASPROGRAMFILEHOST='';
10         
11         ODS _ALL_ CLOSE;
12         OPTIONS DEV=PNG;
13         GOPTIONS XPIXELS=0 YPIXELS=0;
14         FILENAME EGHTML TEMP;
15         ODS HTML(ID=EGHTML) FILE=EGHTML
16             ENCODING='utf-8'
17             STYLE=HTMLBlue
18             NOGTITLE
19             NOGFOOTNOTE
20             GPATH=&amp;amp;sasworklocation
21         ;
NOTE: Writing HTML(EGHTML) Body file: EGHTML
22         
23         GOPTIONS ACCESSIBLE;
24         
25         


26         data fakedata;
27         set sashelp.class;
28         varb = catx(" ",name,age);
29         
30         run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.FAKEDATA has 19 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
      

31         
32         proc sort data=fakedata;
33         by age;
34         run;

NOTE: There were 19 observations read from the data set WORK.FAKEDATA.
NOTE: The data set WORK.FAKEDATA has 19 observations and 6 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
      

35         
36         proc format;
37         value w_by
38         11="1.25in"
39         12="1.25in"
2                                                          The SAS System                               13:35 Tuesday, June 20, 2023

40         			13="2.0in"
41         			14="3.0in"
42         			15="1.25in"
43         			16="1.25in"
44         			;
NOTE: Format W_BY is already on the library WORK.FORMATS.
NOTE: Format W_BY has been output.
45         run;

NOTE: PROCEDURE FORMAT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

46         
47         options nobyline;
48         
49         %let path=&amp;amp;link_shared_folder\SAS\ODS\;
50         
51         
52         ods excel file="&amp;amp;path\diff_width.xlsx"
53         
54         options (sheet_name='Age #byval1');
55         
56         proc report data=fakedata out=a123;
57         by age;
58         column age varb sex height weight;
59         define age /order page;
60         define varb / display ;
61         define sex / display;
62         define height / display;
63         define weight / display;
64         compute before age;
65         	holdage = age;
66         endcomp;
67         compute before _page_ /style=SystemTitle;
68         line 'THIS BYGROUP is for Age: ' Age 2.0;
69         endcomp;
70         compute varb;
71         length svar $50;
72         	svar = catt ('style={width=',put (holdage,w_by.),'}');
73         	call define (_col_,'style',svar);
74         endcomp;
75         run;

NOTE: Variable Age already exists on file WORK.A123, using Age2 instead.
ERROR 22-322: Syntax error, expecting one of the following: a name, a format name, !, *, @, DYNAMIC, EXPRESSION, RESOLVE, SYMGET, 
              _UNDEFINE_, _UNDEF_, _UND_, |.  
ERROR 76-322: Syntax error, statement will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: a name, a format name, !, *, @, DYNAMIC, EXPRESSION, RESOLVE, SYMGET, 
              _UNDEFINE_, _UNDEF_, _UND_, |.  
ERROR 76-322: Syntax error, statement will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: a name, a format name, !, *, @, DYNAMIC, EXPRESSION, RESOLVE, SYMGET, 
              _UNDEFINE_, _UNDEF_, _UND_, |.  
ERROR 76-322: Syntax error, statement will be ignored.
NOTE: The above message was for the following BY group:
      Age=11
ERROR 22-322: Syntax error, expecting one of the following: a name, a format name, !, *, @, DYNAMIC, EXPRESSION, RESOLVE, SYMGET, 
3                                                          The SAS System                               13:35 Tuesday, June 20, 2023

              _UNDEFINE_, _UNDEF_, _UND_, |.  
ERROR 76-322: Syntax error, statement will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: a name, a format name, !, *, @, DYNAMIC, EXPRESSION, RESOLVE, SYMGET, 
              _UNDEFINE_, _UNDEF_, _UND_, |.  
ERROR 76-322: Syntax error, statement will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: a name, a format name, !, *, @, DYNAMIC, EXPRESSION, RESOLVE, SYMGET, 
              _UNDEFINE_, _UNDEF_, _UND_, |.  
ERROR 76-322: Syntax error, statement will be ignored.
NOTE: The above message was for the following BY group:
      Age=12
ERROR 22-322: Syntax error, expecting one of the following: a name, a format name, !, *, @, DYNAMIC, EXPRESSION, RESOLVE, SYMGET, 
              _UNDEFINE_, _UNDEF_, _UND_, |.  
ERROR 76-322: Syntax error, statement will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: a name, a format name, !, *, @, DYNAMIC, EXPRESSION, RESOLVE, SYMGET, 
              _UNDEFINE_, _UNDEF_, _UND_, |.  
ERROR 76-322: Syntax error, statement will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: a name, a format name, !, *, @, DYNAMIC, EXPRESSION, RESOLVE, SYMGET, 
              _UNDEFINE_, _UNDEF_, _UND_, |.  
ERROR 76-322: Syntax error, statement will be ignored.
NOTE: The above message was for the following BY group:
      Age=13
ERROR 22-322: Syntax error, expecting one of the following: a name, a format name, !, *, @, DYNAMIC, EXPRESSION, RESOLVE, SYMGET, 
              _UNDEFINE_, _UNDEF_, _UND_, |.  
ERROR 76-322: Syntax error, statement will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: a name, a format name, !, *, @, DYNAMIC, EXPRESSION, RESOLVE, SYMGET, 
              _UNDEFINE_, _UNDEF_, _UND_, |.  
ERROR 76-322: Syntax error, statement will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: a name, a format name, !, *, @, DYNAMIC, EXPRESSION, RESOLVE, SYMGET, 
              _UNDEFINE_, _UNDEF_, _UND_, |.  
ERROR 76-322: Syntax error, statement will be ignored.
NOTE: The above message was for the following BY group:
      Age=14
ERROR 22-322: Syntax error, expecting one of the following: a name, a format name, !, *, @, DYNAMIC, EXPRESSION, RESOLVE, SYMGET, 
              _UNDEFINE_, _UNDEF_, _UND_, |.  
ERROR 76-322: Syntax error, statement will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: a name, a format name, !, *, @, DYNAMIC, EXPRESSION, RESOLVE, SYMGET, 
              _UNDEFINE_, _UNDEF_, _UND_, |.  
ERROR 76-322: Syntax error, statement will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: a name, a format name, !, *, @, DYNAMIC, EXPRESSION, RESOLVE, SYMGET, 
              _UNDEFINE_, _UNDEF_, _UND_, |.  
ERROR 76-322: Syntax error, statement will be ignored.
NOTE: The above message was for the following BY group:
      Age=15
ERROR 22-322: Syntax error, expecting one of the following: a name, a format name, !, *, @, DYNAMIC, EXPRESSION, RESOLVE, SYMGET, 
              _UNDEFINE_, _UNDEF_, _UND_, |.  
ERROR 76-322: Syntax error, statement will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: a name, a format name, !, *, @, DYNAMIC, EXPRESSION, RESOLVE, SYMGET, 
              _UNDEFINE_, _UNDEF_, _UND_, |.  
ERROR 76-322: Syntax error, statement will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: a name, a format name, !, *, @, DYNAMIC, EXPRESSION, RESOLVE, SYMGET, 
              _UNDEFINE_, _UNDEF_, _UND_, |.  
ERROR 76-322: Syntax error, statement will be ignored.
NOTE: The above message was for the following BY group:
      Age=16
NOTE: There were 19 observations read from the data set WORK.FAKEDATA.
NOTE: The data set WORK.A123 has 31 observations and 7 variables.
NOTE: PROCEDURE REPORT used (Total process time):
      real time           0.29 seconds
4                                                          The SAS System                               13:35 Tuesday, June 20, 2023

      cpu time            0.20 seconds
      

76         ods excel close;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2023 12:13:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-Report-amp-ODS-excel-define-columnwidth-in-function-of/m-p/881534#M82803</guid>
      <dc:creator>fre</dc:creator>
      <dc:date>2023-06-20T12:13:59Z</dc:date>
    </item>
  </channel>
</rss>

