<?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: loosing leading zeros during proc export in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/loosing-leading-zeros-during-proc-export/m-p/450228#M113366</link>
    <description>&lt;P&gt;Or adding a special character before it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;/P&gt;
&lt;P&gt;format app_date mmddyy10.;&lt;/P&gt;
&lt;P&gt;date_mth = month(app_date);&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;date_mth1 = cats('09'x,put(date_mth,&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;Z2.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;run:&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 01 Apr 2018 11:18:53 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2018-04-01T11:18:53Z</dc:date>
    <item>
      <title>loosing leading zeros during proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loosing-leading-zeros-during-proc-export/m-p/450156#M113348</link>
      <description>&lt;P&gt;data have;&lt;/P&gt;
&lt;P&gt;format app_date mmddyy10.;&lt;/P&gt;
&lt;P&gt;date_mth = month(app_date);&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;date_mth1 = put(date_mth,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;Z2.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;run:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;output&lt;BR /&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp; app_date&amp;nbsp;&amp;nbsp; date_mth&lt;BR /&gt;12&amp;nbsp;&amp;nbsp;&amp;nbsp; 12/09/2018&amp;nbsp; 12&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;65&amp;nbsp;&amp;nbsp;&amp;nbsp; 06/15/2018&amp;nbsp; 06&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;This works ok in the datastep&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;proc export outfile = "\\myserver\have.xlsb"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;data= have&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;label&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;DBMS = excelcs replace;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Sheet = "Data";&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Server = "myserver"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Output&lt;BR /&gt;LOAN_ID&amp;nbsp;&amp;nbsp;&amp;nbsp; APPLICATION DATE&amp;nbsp;&amp;nbsp; DATE MONTH&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;output example&lt;BR /&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app_date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date_mth&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;&lt;FONT face="Courier New"&gt;12&amp;nbsp;&amp;nbsp;&amp;nbsp; 12/9/2018&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;65&amp;nbsp;&amp;nbsp;&amp;nbsp; 6/15/2018&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;The exported output correctly eliminates the leading zeroes in the app_date however I want to retain the leading zero in date_mth just as I did in the datastep using the put statement. So 6 should be 06 however it truncates during export.&amp;nbsp; How do I get it back?&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 31 Mar 2018 15:46:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loosing-leading-zeros-during-proc-export/m-p/450156#M113348</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2018-03-31T15:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: loosing leading zeros during proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loosing-leading-zeros-during-proc-export/m-p/450162#M113351</link>
      <description>&lt;P&gt;If you want to tell Excel how to format the data you probably need to use ODS EXCEL instead of PROC EXPORT.&lt;/P&gt;
&lt;P&gt;Try this program.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input id app_date char_mth :$2. ;
  informat app_date mmddyy.;
  format app_date yymmdd10. ;
  date_mth = month(app_date);
cards;
12    12/09/2018  12
65    06/15/2018  06
;

proc export data=have 
  outfile='c:\downloads\test1.xlsx' replace
  dbms=xlsx
;
run;

ods excel file='c:\downloads\test2.xlsx' ;
proc print data=have ;
 var id ;
 var app_date / style(data)={tagattr='type:Date format:mm/dd/yyyy'}; 
 var char_mth / style(data)={tagattr='type:text'};
 var date_mth / style(data)={tagattr='format:00'} ;
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="image.png" style="width: 322px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/19556iA5E453055108D101/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 31 Mar 2018 17:04:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loosing-leading-zeros-during-proc-export/m-p/450162#M113351</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-03-31T17:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: loosing leading zeros during proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loosing-leading-zeros-during-proc-export/m-p/450228#M113366</link>
      <description>&lt;P&gt;Or adding a special character before it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;/P&gt;
&lt;P&gt;format app_date mmddyy10.;&lt;/P&gt;
&lt;P&gt;date_mth = month(app_date);&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;date_mth1 = cats('09'x,put(date_mth,&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;Z2.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;run:&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Apr 2018 11:18:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loosing-leading-zeros-during-proc-export/m-p/450228#M113366</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-04-01T11:18:53Z</dc:date>
    </item>
  </channel>
</rss>

