<?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 DROPPING LEADING ZEROES ON CHARACTER VARIABLE in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-DROPPING-LEADING-ZEROES-ON-CHARACTER-VARIABLE/m-p/786051#M250913</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/393528"&gt;@LMSSAS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I had a lot of trouble with that too. In Denmark Socia Security Numbers are 10 digits, first digit is often a zero, and it is stored as Char in SAS.&lt;/P&gt;
&lt;P&gt;I didn't succeded in preserving the leading zero until I discovered that it works if the SSN is converted to a Numeric variable and given the format Z10.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 14 Dec 2021 20:57:20 GMT</pubDate>
    <dc:creator>ErikLund_Jensen</dc:creator>
    <dc:date>2021-12-14T20:57:20Z</dc:date>
    <item>
      <title>ODS EXCEL DROPPING LEADING ZEROES ON CHARACTER VARIABLE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-DROPPING-LEADING-ZEROES-ON-CHARACTER-VARIABLE/m-p/786048#M250911</link>
      <description>&lt;P&gt;I have a SAS data set that I'm exporting to excel using ODS and it is dropping the leading zeros. Below is my code, I am not getting an error but the data is still dropping the zeros, as if it isn't recognizing the code. The variable I am working with trying to keep the leading zeros is "Group" and even though it is numbers it is a Char in SAS.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;ods excel file="/prod/SalesOperations/appdata/shared/Blue_Vision_Master_Renewal.xlsx" options (autofilter='all' sheet_name="Current_Month_Renewals");
ods excel options(sheet_name="RBMS_Health" autofilter='all');
proc report data=RBMS_BVMR;
Define Group / display Group 
style(Column)=[font_size=8pt width=.7in tagattr='Format:@'];
run;

ods excel options(sheet_name="Dental" autofilter='all');
proc report data=RBMS_HPS_DENTAL_FINAL;
Define Group / display Group 
style(Column)=[font_size=8pt width=.7in tagattr='Format:@'];
run;

ods excel options(sheet_name="Vision" autofilter='all');
proc report data=RBMS_HPS_VISION_FINAL;
Define Group / display Group 
style(Column)=[font_size=8pt width=.7in tagattr='Format:@'];
run;

ods excel options(sheet_name="Life" autofilter='all');
proc report data=Life;
Define Group / display Group 
style(Column)=[font_size=8pt width=.7in tagattr='Format:@'];
run;
ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Dec 2021 20:15:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-DROPPING-LEADING-ZEROES-ON-CHARACTER-VARIABLE/m-p/786048#M250911</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2021-12-14T20:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: ODS EXCEL DROPPING LEADING ZEROES ON CHARACTER VARIABLE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-DROPPING-LEADING-ZEROES-ON-CHARACTER-VARIABLE/m-p/786049#M250912</link>
      <description>&lt;P&gt;Try adding a FORMAT= option to your DEFINE statement.&lt;/P&gt;
&lt;P&gt;Not sure why it works.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  id = put(_n_,z5.);
  set sashelp.class;
run;

ods excel file='c:\downloads\zeros.xlsx'
  options 
   (autofilter='all' sheet_name="Current_Month_Renewals")
;
proc report data=test;
  define id / display Group format=$5. style(Column)=[font_size=8pt width=.7in tagattr='Format:@'];
run;

ods excel close;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Dec 2021 20:24:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-DROPPING-LEADING-ZEROES-ON-CHARACTER-VARIABLE/m-p/786049#M250912</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-14T20:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: ODS EXCEL DROPPING LEADING ZEROES ON CHARACTER VARIABLE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-DROPPING-LEADING-ZEROES-ON-CHARACTER-VARIABLE/m-p/786051#M250913</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/393528"&gt;@LMSSAS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I had a lot of trouble with that too. In Denmark Socia Security Numbers are 10 digits, first digit is often a zero, and it is stored as Char in SAS.&lt;/P&gt;
&lt;P&gt;I didn't succeded in preserving the leading zero until I discovered that it works if the SSN is converted to a Numeric variable and given the format Z10.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Dec 2021 20:57:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-DROPPING-LEADING-ZEROES-ON-CHARACTER-VARIABLE/m-p/786051#M250913</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2021-12-14T20:57:20Z</dc:date>
    </item>
    <item>
      <title>Re: ODS EXCEL DROPPING LEADING ZEROES ON CHARACTER VARIABLE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-DROPPING-LEADING-ZEROES-ON-CHARACTER-VARIABLE/m-p/786063#M250924</link>
      <description>&lt;P&gt;This really seems like a bug in PROC REPORT and/or ODS EXCEL.&lt;/P&gt;
&lt;P&gt;Just attaching the $ format to a character variable causes the cell to be properly configured in EXCEL as containing text instead of numbers.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Dec 2021 21:46:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-DROPPING-LEADING-ZEROES-ON-CHARACTER-VARIABLE/m-p/786063#M250924</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-14T21:46:44Z</dc:date>
    </item>
    <item>
      <title>Re: ODS EXCEL DROPPING LEADING ZEROES ON CHARACTER VARIABLE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-DROPPING-LEADING-ZEROES-ON-CHARACTER-VARIABLE/m-p/786067#M250927</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My guess is that with the explicit character format=$5.means when SAS creates the output it knows that the result sets the variable type in the xml hidden to the proper type in the XLSX file. Otherwise a "general" field is likely created for the Excel regardless of variable type, which will treat values like "000123" as a numeric 123. The question may be why the default Format&amp;nbsp; is insufficient to do the same thing unless the default format for the OP is a custom format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I vaguely remember a solution to an ODS EXCELXP question that was similar where the issue was regardless of the TAGATTR format the type that appeared in the created XML was incorrect. I don't recall the specific syntax but a type:'string' or similar had to be added to the TAGATTR options.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Try adding a FORMAT= option to your DEFINE statement.&lt;/P&gt;
&lt;P&gt;Not sure why it works.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  id = put(_n_,z5.);
  set sashelp.class;
run;

ods excel file='c:\downloads\zeros.xlsx'
  options 
   (autofilter='all' sheet_name="Current_Month_Renewals")
;
proc report data=test;
  define id / display Group format=$5. style(Column)=[font_size=8pt width=.7in tagattr='Format:@'];
run;

ods excel close;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Dec 2021 21:51:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-DROPPING-LEADING-ZEROES-ON-CHARACTER-VARIABLE/m-p/786067#M250927</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-12-14T21:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: ODS EXCEL DROPPING LEADING ZEROES ON CHARACTER VARIABLE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-DROPPING-LEADING-ZEROES-ON-CHARACTER-VARIABLE/m-p/786071#M250931</link>
      <description>&lt;P&gt;Found the issue.&amp;nbsp; &amp;nbsp;&lt;A href="https://support.sas.com/kb/57/620.html" target="_blank"&gt;https://support.sas.com/kb/57/620.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems that ODS EXCEL is ignoring the &lt;FONT face="courier new,courier"&gt;format:text&lt;/FONT&gt; tag.&amp;nbsp; Instead you need to set &lt;FONT face="courier new,courier"&gt;type=String&lt;/FONT&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Define Group / display Group 
  style(Column)=[font_size=8pt width=.7in tagattr='type:String']
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As to why attaching a format to the variable and/or report column makes any difference I am still not sure.&amp;nbsp; It must be that somehow PROC REPORT is for whatever random reason changing the TYPE it sets for the cell to string only when you have a format attached the variable (either in the source dataset or in the DEFINE statement) even if the variable is a character variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Dec 2021 22:14:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-DROPPING-LEADING-ZEROES-ON-CHARACTER-VARIABLE/m-p/786071#M250931</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-14T22:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: ODS EXCEL DROPPING LEADING ZEROES ON CHARACTER VARIABLE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-DROPPING-LEADING-ZEROES-ON-CHARACTER-VARIABLE/m-p/786164#M250970</link>
      <description>Tom, Thank you, this worked!!&lt;BR /&gt;&lt;BR /&gt;I appreciate the help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 15 Dec 2021 13:17:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-DROPPING-LEADING-ZEROES-ON-CHARACTER-VARIABLE/m-p/786164#M250970</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2021-12-15T13:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: ODS EXCEL DROPPING LEADING ZEROES ON CHARACTER VARIABLE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-DROPPING-LEADING-ZEROES-ON-CHARACTER-VARIABLE/m-p/786165#M250971</link>
      <description>Thank you for your time !</description>
      <pubDate>Wed, 15 Dec 2021 13:18:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-DROPPING-LEADING-ZEROES-ON-CHARACTER-VARIABLE/m-p/786165#M250971</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2021-12-15T13:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: ODS EXCEL DROPPING LEADING ZEROES ON CHARACTER VARIABLE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-DROPPING-LEADING-ZEROES-ON-CHARACTER-VARIABLE/m-p/786166#M250972</link>
      <description>&lt;P&gt;Thank you for your time!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Dec 2021 13:18:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-DROPPING-LEADING-ZEROES-ON-CHARACTER-VARIABLE/m-p/786166#M250972</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2021-12-15T13:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: ODS EXCEL DROPPING LEADING ZEROES ON CHARACTER VARIABLE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-DROPPING-LEADING-ZEROES-ON-CHARACTER-VARIABLE/m-p/786167#M250973</link>
      <description>Thank you for your time!</description>
      <pubDate>Wed, 15 Dec 2021 13:18:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-DROPPING-LEADING-ZEROES-ON-CHARACTER-VARIABLE/m-p/786167#M250973</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2021-12-15T13:18:53Z</dc:date>
    </item>
  </channel>
</rss>

