<?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 PROC ODSTABLE, format not being applied to column in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-ODSTABLE-format-not-being-applied-to-column/m-p/714731#M24821</link>
    <description>&lt;P&gt;Please check me on this code.&amp;nbsp; What am I missing?&amp;nbsp; Is this a bug?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using SAShelp.Cars, I'm creating a character format, $MAKE, which maps the first three (3) characters of the column Make to the full text.&amp;nbsp; Then I'm attempting to create a table using ODSTABLE giving the 3 character data to the procedure and I'm wanting the procedure to transform that data by the format.&amp;nbsp; This is suppose to work like&amp;nbsp;the example here:&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=odsproc&amp;amp;docsetTarget=p0rbbp8813v8vkn1bql6je6mz0n8.htm&amp;amp;locale=en#p0rbbp8813v8vkn1bql6je6mz0n8"&gt;SAS Help Center: Defining Variables with the COLUMN Statement&lt;/A&gt;&amp;nbsp;-- I think. (??)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options nofmterr nocenter;

data cntlin (keep=FMTNAME end start label type );
  set SAShelp.Cars (obs=50);
    by Make ;
  if first.Make then do;
    FMTNAME="Make";
    type="C";
    length start end $3;
      start=substr(Make,1,3);
      format start $Make.;
    end=start;
    label=Make;
    output;
  end;
proc format cntlin=&amp;amp;sysLast;
run;

proc odstable data=cntlin(Keep=start ) PAGEBREAK=No;
  column   start ;
  define start;
    format=$make.;
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I get this output like this:&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;LI-CODE lang="sas"&gt;start
Acu
Aud
BMW
Bui&lt;/LI-CODE&gt;&lt;/DIV&gt;
&lt;P&gt;I expected this:&lt;/P&gt;
&lt;DIV&gt;&lt;LI-CODE lang="sas"&gt;start
Acura
Audi
BMW
Buick&lt;/LI-CODE&gt;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Wed, 27 Jan 2021 19:45:46 GMT</pubDate>
    <dc:creator>PhilC</dc:creator>
    <dc:date>2021-01-27T19:45:46Z</dc:date>
    <item>
      <title>PROC ODSTABLE, format not being applied to column</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-ODSTABLE-format-not-being-applied-to-column/m-p/714731#M24821</link>
      <description>&lt;P&gt;Please check me on this code.&amp;nbsp; What am I missing?&amp;nbsp; Is this a bug?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using SAShelp.Cars, I'm creating a character format, $MAKE, which maps the first three (3) characters of the column Make to the full text.&amp;nbsp; Then I'm attempting to create a table using ODSTABLE giving the 3 character data to the procedure and I'm wanting the procedure to transform that data by the format.&amp;nbsp; This is suppose to work like&amp;nbsp;the example here:&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=odsproc&amp;amp;docsetTarget=p0rbbp8813v8vkn1bql6je6mz0n8.htm&amp;amp;locale=en#p0rbbp8813v8vkn1bql6je6mz0n8"&gt;SAS Help Center: Defining Variables with the COLUMN Statement&lt;/A&gt;&amp;nbsp;-- I think. (??)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options nofmterr nocenter;

data cntlin (keep=FMTNAME end start label type );
  set SAShelp.Cars (obs=50);
    by Make ;
  if first.Make then do;
    FMTNAME="Make";
    type="C";
    length start end $3;
      start=substr(Make,1,3);
      format start $Make.;
    end=start;
    label=Make;
    output;
  end;
proc format cntlin=&amp;amp;sysLast;
run;

proc odstable data=cntlin(Keep=start ) PAGEBREAK=No;
  column   start ;
  define start;
    format=$make.;
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I get this output like this:&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;LI-CODE lang="sas"&gt;start
Acu
Aud
BMW
Bui&lt;/LI-CODE&gt;&lt;/DIV&gt;
&lt;P&gt;I expected this:&lt;/P&gt;
&lt;DIV&gt;&lt;LI-CODE lang="sas"&gt;start
Acura
Audi
BMW
Buick&lt;/LI-CODE&gt;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 27 Jan 2021 19:45:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-ODSTABLE-format-not-being-applied-to-column/m-p/714731#M24821</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2021-01-27T19:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: PROC ODSTABLE, format not being applied to column</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-ODSTABLE-format-not-being-applied-to-column/m-p/714800#M24822</link>
      <description>&lt;P&gt;First mistake:&lt;/P&gt;
&lt;PRE&gt;557  data cntlin (keep=FMTNAME end start label type );
558    set SAShelp.Cars (obs=50);
559      by Make ;
560    if first.Make then do;
561      FMTNAME="Make";
562      type="C";
563      length start end $3;
564        start=substr(Make,1,3);
565        format start $Make.;
                        ------
                        48
ERROR 48-59: The format $MAKE was not found or could not be loaded.

566      end=start;
567      label=Make;
568      output;
569    end;
&lt;/PRE&gt;
&lt;P&gt;The first time this data step runs the format is not defined and creates an error and no data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next you didn't look at all the documentation related to setting formats. If you don't specify a format_width option the length of the variable seems to be the default display width. So you override that with a Format_width:&lt;/P&gt;
&lt;PRE&gt;proc odstable data=cntlin(Keep=start ) PAGEBREAK=No;
  column   start ;
  define start;
    
    format=$make10.;

  end;
run;

&lt;/PRE&gt;
&lt;P&gt;You may need to consider specifying decimals when dealing with numeric values.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 20:45:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-ODSTABLE-format-not-being-applied-to-column/m-p/714800#M24822</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-27T20:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: PROC ODSTABLE, format not being applied to column</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-ODSTABLE-format-not-being-applied-to-column/m-p/714819#M24823</link>
      <description>&lt;P&gt;Hey, don't give me that kind of stuff.&amp;nbsp; What about running options nofmterr?&amp;nbsp; I did that on purpose &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...&lt;EM&gt;Format width&lt;/EM&gt;... huh.&amp;nbsp; I have stared at this for a day!&amp;nbsp; I ruled it out at some point, falsely.&amp;nbsp; Well I guess I deserve it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OK I see, I was looking at the datasets and inside the datasets the formats displayed longer than three characters there.&amp;nbsp; Now I see.&amp;nbsp; The default width of Make is in fact 5, if you check.&amp;nbsp; So PROC ODSTABLE does have a weird behavior.&amp;nbsp; It is as if the procedure is confusing the default width of the format with the character length of the column.&amp;nbsp; I have a point, do I not?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 21:44:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-ODSTABLE-format-not-being-applied-to-column/m-p/714819#M24823</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2021-01-27T21:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: PROC ODSTABLE, format not being applied to column</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-ODSTABLE-format-not-being-applied-to-column/m-p/714844#M24827</link>
      <description>&lt;P&gt;While I think that specifying a the width in the font may be the overall easiest you could also use:&lt;/P&gt;
&lt;PRE&gt;proc odstable data=cntlin(Keep=start ) PAGEBREAK=No;
  column   start ;
  define start;
    
    format=$make.;
    font_width=10;
  end;
run;
&lt;/PRE&gt;
&lt;P&gt;Or make the variable with a length at least as great as the expected display width.&lt;/P&gt;
&lt;P&gt;This does work for your expected output:&lt;/P&gt;
&lt;PRE&gt;data cntlin (keep=FMTNAME end start label type );
  set SAShelp.Cars (obs=50);
    by Make ;
  if first.Make then do;
    FMTNAME="Make";
    type="C";
    length start end $15;
      start=substr(Make,1,3);
    end=start;
    label=Make;
    output;
  end;
run;
proc format cntlin=cntlin ;
run;

proc odstable data=cntlin(Keep=start ) PAGEBREAK=No;
  column   start ;
  define start;
    
    format=$make.;
  end;
run;

&lt;/PRE&gt;
&lt;P&gt;Even though the defined length of Start is 15, with the values assigned of length 3 the default width is long enough for the 5 character labels (all that were selected for making the format).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 23:38:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-ODSTABLE-format-not-being-applied-to-column/m-p/714844#M24827</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-27T23:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: PROC ODSTABLE, format not being applied to column</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-ODSTABLE-format-not-being-applied-to-column/m-p/714960#M24829</link>
      <description>&lt;P&gt;You're definitely right, but I'm going to report the bug.&amp;nbsp; Thanks for your input.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 12:40:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-ODSTABLE-format-not-being-applied-to-column/m-p/714960#M24829</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2021-01-28T12:40:37Z</dc:date>
    </item>
  </channel>
</rss>

