<?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: Help adding  leading zeros to .txt output in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Help-adding-leading-zeros-to-txt-output/m-p/138314#M11093</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I faced this problem in my previous report and it solved by giving the tagattr="format:@" to get the leading zero's in excel.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;define 'Co-op'n&amp;nbsp;&amp;nbsp; / display&amp;nbsp; "Co-Op" style(column)=[ indent=4 tagattr="format:@" just=center background=cxffffff foreground=stbr] ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 13 Jan 2014 12:01:42 GMT</pubDate>
    <dc:creator>Vish33</dc:creator>
    <dc:date>2014-01-13T12:01:42Z</dc:date>
    <item>
      <title>Help adding  leading zeros to .txt output</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Help-adding-leading-zeros-to-txt-output/m-p/138310#M11089</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am writing a program to output a SAS data set to a .txt file. The issues this certain field in SAS is a character field with numbers which normally would not be a problem except that in the out output they want leading zeros added to the field. I have to problem changing the character field to a numeric field either. Which ever way I can add and display the leading zeros. I've tried the tagattr format that I've used when outputting to excel but this is not working. Any ideas would be helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Jan 2014 23:25:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Help-adding-leading-zeros-to-txt-output/m-p/138310#M11089</guid>
      <dc:creator>Patty</dc:creator>
      <dc:date>2014-01-10T23:25:44Z</dc:date>
    </item>
    <item>
      <title>Re: Help adding  leading zeros to .txt output</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Help-adding-leading-zeros-to-txt-output/m-p/138311#M11090</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sure it is char&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;method 1&lt;/P&gt;&lt;P&gt;- &lt;A href="http://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#n0qscq9436n6xon1sthoejn7jpml.htm" title="http://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#n0qscq9436n6xon1sthoejn7jpml.htm"&gt;SAS(R) 9.3 Functions and CALL Routines: Reference&lt;/A&gt; (right align)&lt;/P&gt;&lt;P&gt;- &lt;A href="http://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#p05ww22zp7lcg3n1bjk7v93tscyo.htm" title="http://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#p05ww22zp7lcg3n1bjk7v93tscyo.htm"&gt;SAS(R) 9.3 Functions and CALL Routines: Reference&lt;/A&gt; (translate)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;method 2&lt;/P&gt;&lt;P&gt;- convert to number (input fucntion) and use the numeric format (Base sas limt to ca 12 digits precision)&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/leforinforref/63324/HTML/default/viewer.htm#p09lpr3kmbh8fen1qepuv6zc1ldd.htm" title="http://support.sas.com/documentation/cdl/en/leforinforref/63324/HTML/default/viewer.htm#p09lpr3kmbh8fen1qepuv6zc1ldd.htm"&gt;- SAS(R) 9.3 Formats and Informats: Reference&lt;/A&gt; (Zw.d format)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;method ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Jan 2014 14:23:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Help-adding-leading-zeros-to-txt-output/m-p/138311#M11090</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-01-11T14:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: Help adding  leading zeros to .txt output</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Help-adding-leading-zeros-to-txt-output/m-p/138312#M11091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are writing to a text file there is no way to attach any attributes.&lt;/P&gt;&lt;P&gt;If the values inside the character variables have leading zeros then they will be preserved by SAS, if you are not seeing them then the problem is with the tool you are using to view the text file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the values do not have leading zeros then you will need to convert them.&lt;/P&gt;&lt;P&gt;So if your character variable is length 10 and all values are integers then you could use something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;myvar = put(input(myvar,10,),z10.);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Jan 2014 14:29:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Help-adding-leading-zeros-to-txt-output/m-p/138312#M11091</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-01-11T14:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: Help adding  leading zeros to .txt output</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Help-adding-leading-zeros-to-txt-output/m-p/138313#M11092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp; As Tom explained, if you create ASCII text file, such as a CSV file, that has leading zeroes and then open the file with Excel, I believe that Excel will not respect leading zeroes. So you will either need to adjust the value in Excel or you will need to change the method that you use to create your output. For example, if you run the code below, you WILL see zeroes if you open the CSV file in Notepad, but you will NOT see zeroes if you open the CSV file with Excel. Either the MSOFFICE2K output (which is HTML, simply named as XLS to "fool" the Windows registry into launching Excel) or the TAGSETS.EXCELXP output (which is XML) will show zeroes&amp;nbsp; in Excel.&lt;/P&gt;&lt;P&gt;Cynthia&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods csv file='c:\temp\leadzero_comma.csv';&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;proc print data=sashelp.class;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; ** 1) will *NOT* see zeroes in Excel;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; ** *WILL* see zeroes in Notepad -- which means that SAS did the right thing ;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; ** and EXCEL is not respecting the leading zeroes;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; var name age height;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; format age z5. height z8.2;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;run;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods csv close;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods msoffice2k file='c:\temp\leadzero_mso.xls' style=sasweb;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;proc print data=sashelp.class;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; ** 2) will see zeroes in Excel;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; var name;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; var age / style(column)={htmlstyle='mso-number-format:00000'};&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; var height/ style(column)={htmlstyle='mso-number-format:00000.00'};&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; run;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods msoffice2k close;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods tagsets.excelxp file='c:\temp\leadzero_xp.xml' style=sasweb;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;proc print data=sashelp.class;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; ** 3) will see zeroes in Excel;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; var name;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; var age / style(column)={tagattr='00000'};&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; var height/ style(column)={tagattr='00000.00'};&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; run;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods tagsets.excelxp close;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Jan 2014 16:19:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Help-adding-leading-zeros-to-txt-output/m-p/138313#M11092</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2014-01-11T16:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: Help adding  leading zeros to .txt output</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Help-adding-leading-zeros-to-txt-output/m-p/138314#M11093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I faced this problem in my previous report and it solved by giving the tagattr="format:@" to get the leading zero's in excel.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;define 'Co-op'n&amp;nbsp;&amp;nbsp; / display&amp;nbsp; "Co-Op" style(column)=[ indent=4 tagattr="format:@" just=center background=cxffffff foreground=stbr] ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jan 2014 12:01:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Help-adding-leading-zeros-to-txt-output/m-p/138314#M11093</guid>
      <dc:creator>Vish33</dc:creator>
      <dc:date>2014-01-13T12:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: Help adding  leading zeros to .txt output</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Help-adding-leading-zeros-to-txt-output/m-p/138315#M11094</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp; This worked. I just had to make 1 adjustment: myvar=put(input(myvar,10&lt;STRONG&gt;.&lt;/STRONG&gt;)z10);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks everyone, All the suggestions opened up possible answers to other issues.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jan 2014 17:47:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Help-adding-leading-zeros-to-txt-output/m-p/138315#M11094</guid>
      <dc:creator>Patty</dc:creator>
      <dc:date>2014-01-16T17:47:02Z</dc:date>
    </item>
  </channel>
</rss>

