<?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: put zeros in front of variable in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/put-zeros-in-front-of-variable/m-p/22795#M3568</link>
    <description>EG4 and Excel are working together for me today, because Excel is honoring the leading zeros when I put SAS data into a character format.&lt;BR /&gt;
&lt;BR /&gt;
If Excel still isn't working for you and you don't mind a little extra work, try result2 below where it concatenates your number with the text 'drop' so your cell reads drop000150.  A quick find replace in Excel corrects the added text around and keeps the leading zeros.&lt;BR /&gt;
&lt;BR /&gt;
data test; set data;&lt;BR /&gt;
length result $10 ;&lt;BR /&gt;
result=put(YourNumber,z6.);&lt;BR /&gt;
result2='drop'||put(YourNumber,z6.);&lt;BR /&gt;
run;</description>
    <pubDate>Thu, 05 Jun 2008 05:21:18 GMT</pubDate>
    <dc:creator>rab24</dc:creator>
    <dc:date>2008-06-05T05:21:18Z</dc:date>
    <item>
      <title>put zeros in front of variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/put-zeros-in-front-of-variable/m-p/22793#M3566</link>
      <description>Hi. I have a numeric variable (length 6) and I would like to place zeros in front of the existing variable (i.e. if the value is 150, I would like it to become 000150). I know that the the z. format will do this, but when I convert this to a character, the zeros are dropped (I need this in character format as I want to export it to excel and keep the zeros).  Any tricks?</description>
      <pubDate>Wed, 04 Jun 2008 06:39:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/put-zeros-in-front-of-variable/m-p/22793#M3566</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-06-04T06:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: put zeros in front of variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/put-zeros-in-front-of-variable/m-p/22794#M3567</link>
      <description>Hi:&lt;BR /&gt;
  If you search the forum listings for ExcelXP and the TAGATTR style attribute, there is a way with ODS to create output files for Excel and basically send a Microsoft leading zero format to Excel.&lt;BR /&gt;
&lt;BR /&gt;
  Otherwise, if you MAKE a character variable with the Z format, SAS will keep the leading zeroes, but as you discovered, Microsoft does not respect the zeroes. The other thing you can do is make a character format and then tell Excel that your number with leading zeroes is a character variable, again, by using the TAGATTR style attribute with TAGSETS.EXCELXP in order to send a Type instruction to Excel.&lt;BR /&gt;
&lt;BR /&gt;
  I don't know of a way with PROC EXPORT to do what you want to do. However, if you search, you should find methods for doing this with ODS.&lt;BR /&gt;
&lt;BR /&gt;
cynthia</description>
      <pubDate>Wed, 04 Jun 2008 13:00:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/put-zeros-in-front-of-variable/m-p/22794#M3567</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-06-04T13:00:03Z</dc:date>
    </item>
    <item>
      <title>Re: put zeros in front of variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/put-zeros-in-front-of-variable/m-p/22795#M3568</link>
      <description>EG4 and Excel are working together for me today, because Excel is honoring the leading zeros when I put SAS data into a character format.&lt;BR /&gt;
&lt;BR /&gt;
If Excel still isn't working for you and you don't mind a little extra work, try result2 below where it concatenates your number with the text 'drop' so your cell reads drop000150.  A quick find replace in Excel corrects the added text around and keeps the leading zeros.&lt;BR /&gt;
&lt;BR /&gt;
data test; set data;&lt;BR /&gt;
length result $10 ;&lt;BR /&gt;
result=put(YourNumber,z6.);&lt;BR /&gt;
result2='drop'||put(YourNumber,z6.);&lt;BR /&gt;
run;</description>
      <pubDate>Thu, 05 Jun 2008 05:21:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/put-zeros-in-front-of-variable/m-p/22795#M3568</guid>
      <dc:creator>rab24</dc:creator>
      <dc:date>2008-06-05T05:21:18Z</dc:date>
    </item>
  </channel>
</rss>

