<?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: when using ods excel ,the output variable 's format is not expected in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/when-using-ods-excel-the-output-variable-s-format-is-not/m-p/879846#M347581</link>
    <description>&lt;P&gt;Thanks all dears:&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/321371"&gt;@A_Kh&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I find a surprisingly simple way to solve the problem, just add "format x $3.;" after" proc print;"!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input x $3.;
datalines;
001
003
005
;
run;
ods listing close ;
ods results off;
filename fbout "d:\result.xlsx";
ods excel (id=fb) file=fbout  options(sheet_interval="none" sheet_name="test");
proc print data=test;format x $3.;run;
ods excel (id=fb) close;
filename fbout clear;
ods listing  ;
ods results on;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 05:04:26 GMT</pubDate>
    <dc:creator>duanzongran</dc:creator>
    <dc:date>2023-06-09T05:04:26Z</dc:date>
    <item>
      <title>when using ods excel ,the output variable 's format is not expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/when-using-ods-excel-the-output-variable-s-format-is-not/m-p/879722#M347543</link>
      <description>&lt;P&gt;DEAR ALL：&lt;/P&gt;
&lt;P&gt;The code as follows：&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input x $3.;
datalines;
001
003
005
;
run;
ods listing close ;
ods results off;
filename fbout "d:\result.xlsx";
ods excel (id=fb) file=fbout  options(sheet_interval="none" sheet_name="test");
proc print data=test;run;
ods excel (id=fb) close;
filename fbout clear;
ods listing  ;
ods results on;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;when i open the excel file "&lt;CODE class=" language-sas"&gt;"d:\result.xlsx";&lt;/CODE&gt;" ,it shows&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="duanzongran_0-1686218261564.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84819i47782EAB85BC5B01/image-size/medium?v=v2&amp;amp;px=400" role="button" title="duanzongran_0-1686218261564.png" alt="duanzongran_0-1686218261564.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;but&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="duanzongran_1-1686218333179.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84820i0279D7A001F17CCA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="duanzongran_1-1686218333179.png" alt="duanzongran_1-1686218333179.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;is what I want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How should I correct my code in sas, not in excel ？&lt;/P&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 10:01:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/when-using-ods-excel-the-output-variable-s-format-is-not/m-p/879722#M347543</guid>
      <dc:creator>duanzongran</dc:creator>
      <dc:date>2023-06-08T10:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: when using ods excel ,the output variable 's format is not expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/when-using-ods-excel-the-output-variable-s-format-is-not/m-p/879730#M347551</link>
      <description>&lt;P&gt;Maybe there are simpler methods, but you can add &lt;A href="https://www.lexjansen.com/nesug/nesug04/pm/pm24.pdf" target="_self"&gt;ASCII 255&lt;/A&gt; in front of your zeros, this unprintable character will force Excel to see the character string as character and not numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
    length x $ 4;
    set test;
    x=cat('&amp;nbsp;',x);
run;
ods excel file="test.xlsx";
proc print data=test1;
run;
ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the CAT function inside the quotes is not a blank, even though it looks like a blank. It is ASCII 255, which you can type by holding down the Alt key, pressing 2 5 5 on the numeric keypad and then letting go of the Alt key. Of course, this prevents the numbers from being treated as numbers in Excel, which may (or may not) be a problem for you.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 12:23:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/when-using-ods-excel-the-output-variable-s-format-is-not/m-p/879730#M347551</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-06-08T12:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: when using ods excel ,the output variable 's format is not expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/when-using-ods-excel-the-output-variable-s-format-is-not/m-p/879759#M347558</link>
      <description>&lt;P&gt;You should search this forum to answers as this is a common topic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The easiest way to fix this is use the XLSX libref engine to just dump the data in Excel instead of trying to use ODS EXCEL to store a report into Excel.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So instead of&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename fbout "d:\result.xlsx";
ods excel (id=fb) file=fbout  options(sheet_interval="none" sheet_name="test");
proc print data=test;run;
ods excel (id=fb) close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Use&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname fbout xlsx "d:\result.xlsx";
data fbout.test;
  set test;
run;
libname fbout close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To fix the ODS output you will need to look into how to use style options to set the TAGATTR attribute to let Excel know the cells the column created for that variable should be treated as TEXT and not GENERAL.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 13:20:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/when-using-ods-excel-the-output-variable-s-format-is-not/m-p/879759#M347558</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-08T13:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: when using ods excel ,the output variable 's format is not expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/when-using-ods-excel-the-output-variable-s-format-is-not/m-p/879766#M347562</link>
      <description>&lt;P&gt;You might also consider Proc Report as an alternative where STYLE attributes forces excel to print values in desired format.&lt;BR /&gt;Eg. the below code prints leading zeros:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=test;
     column _all_; 
     define x/display style(column)={tagattr='format:000'};
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Jun 2023 13:44:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/when-using-ods-excel-the-output-variable-s-format-is-not/m-p/879766#M347562</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2023-06-08T13:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: when using ods excel ,the output variable 's format is not expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/when-using-ods-excel-the-output-variable-s-format-is-not/m-p/879846#M347581</link>
      <description>&lt;P&gt;Thanks all dears:&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/321371"&gt;@A_Kh&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I find a surprisingly simple way to solve the problem, just add "format x $3.;" after" proc print;"!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input x $3.;
datalines;
001
003
005
;
run;
ods listing close ;
ods results off;
filename fbout "d:\result.xlsx";
ods excel (id=fb) file=fbout  options(sheet_interval="none" sheet_name="test");
proc print data=test;format x $3.;run;
ods excel (id=fb) close;
filename fbout clear;
ods listing  ;
ods results on;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 05:04:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/when-using-ods-excel-the-output-variable-s-format-is-not/m-p/879846#M347581</guid>
      <dc:creator>duanzongran</dc:creator>
      <dc:date>2023-06-09T05:04:26Z</dc:date>
    </item>
  </channel>
</rss>

