<?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: Leading Zero Truncating csv export in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Leading-Zero-Truncating-csv-export/m-p/534312#M6294</link>
    <description>&lt;P&gt;As Tom has shown you control the leading zeros using the .z&lt;/P&gt;
&lt;P&gt;using&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; code see how the zeros only pad the spaces in front of the numbers&amp;nbsp; If your output number is larger than the format for the value a decimal is included and the number is converted.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  do i=0,1,2,10,12,112,456,9876,123456789 ;
    z=i;
    format z z8.;
    char=put(i,Z8.);
    output;
  end;
run;

data _null_;
  file log dsd ;
  set test;
  put (_all_) (+0);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="sasSource" style="background-color: transparent; color: #000000; font-family: Consolas,Courier,&amp;amp;quot; courier new&amp;amp;quot;; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;0,00000000,00000000&lt;/DIV&gt;
&lt;DIV class="sasSource" style="background-color: transparent; color: #000000; font-family: Consolas,Courier,&amp;amp;quot; courier new&amp;amp;quot;; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;1,00000001,00000001&lt;/DIV&gt;
&lt;DIV class="sasSource" style="background-color: transparent; color: #000000; font-family: Consolas,Courier,&amp;amp;quot; courier new&amp;amp;quot;; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;2,00000002,00000002&lt;/DIV&gt;
&lt;DIV class="sasSource" style="background-color: transparent; color: #000000; font-family: Consolas,Courier,&amp;amp;quot; courier new&amp;amp;quot;; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;10,00000010,00000010&lt;/DIV&gt;
&lt;DIV class="sasSource" style="background-color: transparent; color: #000000; font-family: Consolas,Courier,&amp;amp;quot; courier new&amp;amp;quot;; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;12,00000012,00000012&lt;/DIV&gt;
&lt;DIV class="sasSource" style="background-color: transparent; color: #000000; font-family: Consolas,Courier,&amp;amp;quot; courier new&amp;amp;quot;; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;112,00000112,00000112&lt;/DIV&gt;
&lt;DIV class="sasSource" style="background-color: transparent; color: #000000; font-family: Consolas,Courier,&amp;amp;quot; courier new&amp;amp;quot;; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;456,00000456,00000456&lt;/DIV&gt;
&lt;DIV class="sasSource" style="background-color: transparent; color: #000000; font-family: Consolas,Courier,&amp;amp;quot; courier new&amp;amp;quot;; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;9876,00009876,00009876&lt;/DIV&gt;
&lt;DIV class="sasSource" style="background-color: transparent; color: #000000; font-family: Consolas,Courier,&amp;amp;quot; courier new&amp;amp;quot;; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;123456789,1.2346E8,1.2346E8&lt;/DIV&gt;</description>
    <pubDate>Sun, 10 Feb 2019 17:45:50 GMT</pubDate>
    <dc:creator>VDD</dc:creator>
    <dc:date>2019-02-10T17:45:50Z</dc:date>
    <item>
      <title>Leading Zero Truncating csv export</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Leading-Zero-Truncating-csv-export/m-p/534299#M6288</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I'm trying to export a SAS table as a CSV file using proc export. I'm not sure why the leading zeros is getting truncated in one of the columns.&lt;/P&gt;&lt;P&gt;I tried to use the ODS csv option and also tried to export as a .txt file but still losing the leading zeroes.&lt;/P&gt;&lt;P&gt;I'm looked up the forums and I'm not sure I was able to find any other solution that works for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just FYI, the file gets imported to a tableau workbook and so the end user is not able to search the data values as it's not accurate.&lt;/P&gt;&lt;P&gt;There are few other values that are longer than these missing values and they appear accurate so I'm not sure if the length is an issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is much appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the proc export code I used.&lt;/P&gt;&lt;P&gt;PROC EXPORT&lt;BR /&gt;DATA= Data_Feb2019&lt;BR /&gt;OUTFILE="\path\Feb 2019 results.csv"&lt;BR /&gt;DBMS = csv REPLACE;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hoping to hear soon!&lt;/P&gt;&lt;P&gt;Ashok&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Feb 2019 16:17:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Leading-Zero-Truncating-csv-export/m-p/534299#M6288</guid>
      <dc:creator>ashoks321</dc:creator>
      <dc:date>2019-02-10T16:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: Leading Zero Truncating csv export</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Leading-Zero-Truncating-csv-export/m-p/534301#M6289</link>
      <description>&lt;P&gt;You need to ask that question on a Tableau forum.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS will not remove the leading zeros when it generates a CSV file.&amp;nbsp; &amp;nbsp;From either a character variable or a numeric variable that is formatted to display them.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  do i=0,1,2,10,12 ;
    z=i;
    format z z2.;
    char=put(i,Z2.);
    output;
  end;
run;

data _null_;
  file log dsd ;
  set test;
  put (_all_) (+0);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;455   data _null_;
456     file log dsd ;
457     set test;
458     put (_all_) (+0);
459   run;

0,00,00
1,01,01
2,02,02
10,10,10
12,12,12&lt;/PRE&gt;</description>
      <pubDate>Sun, 10 Feb 2019 16:24:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Leading-Zero-Truncating-csv-export/m-p/534301#M6289</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-02-10T16:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: Leading Zero Truncating csv export</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Leading-Zero-Truncating-csv-export/m-p/534312#M6294</link>
      <description>&lt;P&gt;As Tom has shown you control the leading zeros using the .z&lt;/P&gt;
&lt;P&gt;using&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; code see how the zeros only pad the spaces in front of the numbers&amp;nbsp; If your output number is larger than the format for the value a decimal is included and the number is converted.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  do i=0,1,2,10,12,112,456,9876,123456789 ;
    z=i;
    format z z8.;
    char=put(i,Z8.);
    output;
  end;
run;

data _null_;
  file log dsd ;
  set test;
  put (_all_) (+0);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="sasSource" style="background-color: transparent; color: #000000; font-family: Consolas,Courier,&amp;amp;quot; courier new&amp;amp;quot;; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;0,00000000,00000000&lt;/DIV&gt;
&lt;DIV class="sasSource" style="background-color: transparent; color: #000000; font-family: Consolas,Courier,&amp;amp;quot; courier new&amp;amp;quot;; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;1,00000001,00000001&lt;/DIV&gt;
&lt;DIV class="sasSource" style="background-color: transparent; color: #000000; font-family: Consolas,Courier,&amp;amp;quot; courier new&amp;amp;quot;; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;2,00000002,00000002&lt;/DIV&gt;
&lt;DIV class="sasSource" style="background-color: transparent; color: #000000; font-family: Consolas,Courier,&amp;amp;quot; courier new&amp;amp;quot;; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;10,00000010,00000010&lt;/DIV&gt;
&lt;DIV class="sasSource" style="background-color: transparent; color: #000000; font-family: Consolas,Courier,&amp;amp;quot; courier new&amp;amp;quot;; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;12,00000012,00000012&lt;/DIV&gt;
&lt;DIV class="sasSource" style="background-color: transparent; color: #000000; font-family: Consolas,Courier,&amp;amp;quot; courier new&amp;amp;quot;; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;112,00000112,00000112&lt;/DIV&gt;
&lt;DIV class="sasSource" style="background-color: transparent; color: #000000; font-family: Consolas,Courier,&amp;amp;quot; courier new&amp;amp;quot;; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;456,00000456,00000456&lt;/DIV&gt;
&lt;DIV class="sasSource" style="background-color: transparent; color: #000000; font-family: Consolas,Courier,&amp;amp;quot; courier new&amp;amp;quot;; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;9876,00009876,00009876&lt;/DIV&gt;
&lt;DIV class="sasSource" style="background-color: transparent; color: #000000; font-family: Consolas,Courier,&amp;amp;quot; courier new&amp;amp;quot;; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;123456789,1.2346E8,1.2346E8&lt;/DIV&gt;</description>
      <pubDate>Sun, 10 Feb 2019 17:45:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Leading-Zero-Truncating-csv-export/m-p/534312#M6294</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-02-10T17:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: Leading Zero Truncating csv export</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Leading-Zero-Truncating-csv-export/m-p/534316#M6295</link>
      <description>&lt;P&gt;if you have&amp;nbsp; tableau desktop, you can directly connect to SAS.&lt;/P&gt;</description>
      <pubDate>Sun, 10 Feb 2019 18:17:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Leading-Zero-Truncating-csv-export/m-p/534316#M6295</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2019-02-10T18:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: Leading Zero Truncating csv export</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Leading-Zero-Truncating-csv-export/m-p/534318#M6296</link>
      <description>Hi Tom, thanks for the reponse.&lt;BR /&gt;I did open the csv file and it seemed the zero truncated in that already. So I'm not totally sure it's a tableau issue.&lt;BR /&gt;I'll try the format changes you suggested.</description>
      <pubDate>Sun, 10 Feb 2019 18:43:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Leading-Zero-Truncating-csv-export/m-p/534318#M6296</guid>
      <dc:creator>ashoks321</dc:creator>
      <dc:date>2019-02-10T18:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: Leading Zero Truncating csv export</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Leading-Zero-Truncating-csv-export/m-p/534319#M6297</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/130161"&gt;@ashoks321&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi Tom, thanks for the reponse.&lt;BR /&gt;I did open the csv file and it seemed the zero truncated in that already. So I'm not totally sure it's a tableau issue.&lt;BR /&gt;I'll try the format changes you suggested.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then you probably opened the file with something else that doesn't understand it. Perhaps Excel? Open the file with a text editor.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename csv temp;
PROC EXPORT
DATA= test
OUTFILE=csv
DBMS = csv REPLACE;
RUN;

data _null_;
 infile csv ;
 input;
 put _infile_;
run&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;i,z,char
0,01,00
1,01,01
2,01,02
10,01,10
12,01,12&lt;/PRE&gt;</description>
      <pubDate>Sun, 10 Feb 2019 19:26:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Leading-Zero-Truncating-csv-export/m-p/534319#M6297</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-02-10T19:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: Leading Zero Truncating csv export</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Leading-Zero-Truncating-csv-export/m-p/534321#M6298</link>
      <description>&lt;P&gt;Just tell Tableau how to treat the field.&lt;/P&gt;
&lt;P&gt;Tableau 10.5&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 563px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27036iCEDE3323F4C04EFC/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 216px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27037i92851171B4036DF8/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>Sun, 10 Feb 2019 19:34:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Leading-Zero-Truncating-csv-export/m-p/534321#M6298</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-02-10T19:34:04Z</dc:date>
    </item>
  </channel>
</rss>

