<?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 Exporting Data with Leading Zeores in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-Data-with-Leading-Zeores/m-p/397851#M19400</link>
    <description>&lt;P&gt;I have an issue where I cannot get values with leading zeroes to appear in my output. &amp;nbsp;I am creating a table that compares SITEID with SUBJID. &amp;nbsp;The middle 3 digits of SUBJID should be the same as SITEID. &amp;nbsp;If this is not the case, it should output the discrepant cases. &amp;nbsp;My SAS dataset looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SITEID &amp;nbsp; &amp;nbsp; SUBJID&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;009&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;102-002-001&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;102-008-002&lt;/P&gt;&lt;P&gt;8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 102-008-008&lt;/P&gt;&lt;P&gt;002 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 102-02-002&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I export the data into an Excel file (I've done both&amp;nbsp;xls and&amp;nbsp;xml&amp;nbsp;using ods tagsets.excelxp), the leading zeroes for SITEID disappear. &amp;nbsp;SITEID is a character variable with length 3. &amp;nbsp;I can't use the z. format because I don't want to force "8" to become "008". &amp;nbsp;Instead, I have used the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=check&amp;amp;check. (drop=checkmsg) noobs label;
    var _all_ / style(data)={tagattr='format:@'};
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have run reports where adding the "style(data)={tagattr='format:@'}" portion to the VAR statement has fixed leading zeroes, date format issues, and any other format problems I have run into when exporting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any idea how I might be able to resolve this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Sep 2017 17:54:50 GMT</pubDate>
    <dc:creator>djbateman</dc:creator>
    <dc:date>2017-09-21T17:54:50Z</dc:date>
    <item>
      <title>Exporting Data with Leading Zeores</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-Data-with-Leading-Zeores/m-p/397851#M19400</link>
      <description>&lt;P&gt;I have an issue where I cannot get values with leading zeroes to appear in my output. &amp;nbsp;I am creating a table that compares SITEID with SUBJID. &amp;nbsp;The middle 3 digits of SUBJID should be the same as SITEID. &amp;nbsp;If this is not the case, it should output the discrepant cases. &amp;nbsp;My SAS dataset looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SITEID &amp;nbsp; &amp;nbsp; SUBJID&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;009&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;102-002-001&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;102-008-002&lt;/P&gt;&lt;P&gt;8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 102-008-008&lt;/P&gt;&lt;P&gt;002 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 102-02-002&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I export the data into an Excel file (I've done both&amp;nbsp;xls and&amp;nbsp;xml&amp;nbsp;using ods tagsets.excelxp), the leading zeroes for SITEID disappear. &amp;nbsp;SITEID is a character variable with length 3. &amp;nbsp;I can't use the z. format because I don't want to force "8" to become "008". &amp;nbsp;Instead, I have used the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=check&amp;amp;check. (drop=checkmsg) noobs label;
    var _all_ / style(data)={tagattr='format:@'};
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have run reports where adding the "style(data)={tagattr='format:@'}" portion to the VAR statement has fixed leading zeroes, date format issues, and any other format problems I have run into when exporting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any idea how I might be able to resolve this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 17:54:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-Data-with-Leading-Zeores/m-p/397851#M19400</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2017-09-21T17:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting Data with Leading Zeores</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-Data-with-Leading-Zeores/m-p/397896#M19402</link>
      <description>&lt;P&gt;Convert the data before hand, create a character variable that is exactly what you want and try ODS EXCEL if you're on SAS 9.4&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 19:15:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-Data-with-Leading-Zeores/m-p/397896#M19402</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-21T19:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting Data with Leading Zeores</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-Data-with-Leading-Zeores/m-p/397936#M19403</link>
      <description>&lt;P&gt;Seems like a bug to me. At least with 9.4 (TS1M2) running on Windows.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 188px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15347iF1EEA3ACE7D4F453/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;If you attach the SAS format $CHAR to the variable then it seems to work. &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: 178px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15349iC1B2A8905C37BE11/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;PRE&gt;&lt;CODE class=" language-sas"&gt;%let path=C:\Downloads ;

data have ;
  length SITEID $5 SUBJID $20 ;
  infile cards dsd truncover ;
  input siteid subjid ;
cards;
009,
,102-002-001
,102-008-002
8,102-008-008
002,102-02-002
;
ods excel file="&amp;amp;path\test1.xlsx" ;

proc print data=have noobs label;
  var _all_ / style={tagattr='format:text'} ;
  format siteid $char5. ;
run;

ods excel close ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 21:26:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-Data-with-Leading-Zeores/m-p/397936#M19403</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-09-21T21:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting Data with Leading Zeores</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-Data-with-Leading-Zeores/m-p/398288#M19417</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let path=C:\temp ;

data have ;
  length SITEID $5 SUBJID $20 ;
  infile cards dsd truncover ;
  input siteid subjid ;
  siteid=cats("09"x,siteid);
cards;
009,
,102-002-001
,102-008-002
8,102-008-008
002,102-02-002
;
ods excel file="&amp;amp;path\test1.xlsx" ;

proc print data=have noobs label;
  var _all_ / style={tagattr='format:text'} ;
run;

ods excel close ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 23 Sep 2017 12:42:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-Data-with-Leading-Zeores/m-p/398288#M19417</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-09-23T12:42:38Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting Data with Leading Zeores</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-Data-with-Leading-Zeores/m-p/398669#M19435</link>
      <description>&lt;P&gt;I am using SAS 9.4 (TS1M2). &amp;nbsp;I changed from ods tagsets.excelxp&amp;nbsp;to ods excel. &amp;nbsp;I also added the $char. format. &amp;nbsp;Neither of those is working for me.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2017 21:15:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-Data-with-Leading-Zeores/m-p/398669#M19435</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2017-09-25T21:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting Data with Leading Zeores</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-Data-with-Leading-Zeores/m-p/398686#M19438</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;ODS Excel isn't production until M3?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/74"&gt;@djbateman&lt;/a&gt;&amp;nbsp;What happens if you don't add any TAGATTR and use a Z or CHAR format?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 00:07:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-Data-with-Leading-Zeores/m-p/398686#M19438</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-26T00:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting Data with Leading Zeores</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-Data-with-Leading-Zeores/m-p/398934#M19450</link>
      <description>&lt;P&gt;Thank you, everyone, for your suggestions. &amp;nbsp;I found my own issue. &amp;nbsp;I should have shared my full code. &amp;nbsp;Maybe then someone would have found my problem sooner.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It turns out that I had additional code in the VAR statement that was apparently&amp;nbsp;causing the issue. &amp;nbsp;I took out "style={tagattr='WRAP:YES'} and reran. &amp;nbsp;Things came out properly. &amp;nbsp;I then moved it to the front, and it also ran fine. &amp;nbsp;I guess the order of style(data) vs. style is a problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In short, this is what I originally&amp;nbsp;had:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=check&amp;amp;check. (drop=checkmsg) noobs label;
	var _all_ / style(data)={tagattr='format:@'} style={tagattr='WRAP:YES'};
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and this is what I&lt;SPAN&gt;&amp;nbsp;have that works&lt;/SPAN&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=check&amp;amp;check. (drop=checkmsg) noobs label;
	var _all_ / style={tagattr='WRAP:YES'} style(data)={tagattr='format:@'};
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 19:44:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-Data-with-Leading-Zeores/m-p/398934#M19450</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2017-09-26T19:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting Data with Leading Zeores</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-Data-with-Leading-Zeores/m-p/398993#M19451</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/74"&gt;@djbateman&lt;/a&gt;:&amp;nbsp;&amp;nbsp; Please mark your diagnosis and prescription as the solution.&amp;nbsp; It's useful information.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 00:51:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-Data-with-Leading-Zeores/m-p/398993#M19451</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-09-27T00:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting Data with Leading Zeores</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-Data-with-Leading-Zeores/m-p/399143#M19456</link>
      <description>&lt;P&gt;&lt;FONT face="verdana,geneva"&gt;The reason why the rearranged code "worked" for you is that the last style override takes precendence.&amp;nbsp; In that case, the Excel number format is applied, but wrap text isn't.&amp;nbsp; Also, you are missing the "location" in your "wrap" override.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="verdana,geneva"&gt;Run this code to see what's happening with the overrides in your original code:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.test;
length siteid $3;
siteid = '009'; output;
siteid = '8';   output;
siteid = '002'; output;
run;

ods _all_ close;

ods tagsets.ExcelXP file='C:\temp\test.xml' style=Printer;
proc print data=work.test;
  var _all_ / style(data)={background=red tagattr='format:@'} style={background=yellow tagattr='wrap:yes'};
run; quit;
ods tagsets.ExcelXP close;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="verdana,geneva"&gt;The background color of the data cells is yellow instead of red, indicating that the last override took precedence, causing you to lose the Excel number format.&amp;nbsp; The background color of the column heading is also yellow.&amp;nbsp; It is the missing "location" in the "wrap" style override is what caused the yellow background in the heading.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="verdana,geneva"&gt;To get around these issues, always specify a "location" for the style override, and combine all attributes into a single override.&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="verdana,geneva"&gt;Does this give you want you want?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var _all_ / style(data)={tagattr='format:@ wrap:yes'};&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;FONT face="verdana,geneva"&gt;Vince DelGobbo&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="verdana,geneva"&gt;SAS R&amp;amp;D&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 12:51:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-Data-with-Leading-Zeores/m-p/399143#M19456</guid>
      <dc:creator>Vince_SAS</dc:creator>
      <dc:date>2017-09-27T12:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting Data with Leading Zeores</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-Data-with-Leading-Zeores/m-p/399258#M19462</link>
      <description>&lt;P&gt;SAS already has a knowledge base entry for this issue. &amp;nbsp;&lt;A href="http://support.sas.com/kb/57/620.html" target="_blank"&gt;http://support.sas.com/kb/57/620.html&lt;/A&gt; &amp;nbsp;&lt;/P&gt;
&lt;H2&gt;Problem Note&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;I&gt;57620:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/I&gt;The text format is ignored when it is passed using the TAGATTR= attribute with the ODS Destination for Excel&lt;/H2&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The solution is the use to set the Excel TYPE and not the FORMAT.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;style(data)={tagattr="type:String"}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The example in Problem Note 57620 is a numeric variable with Z. format, but the same solution works for character variables.&lt;/P&gt;
&lt;P&gt;Why you need to tell SAS that you character variables should be type string in Excel I don't know.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 16:38:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Exporting-Data-with-Leading-Zeores/m-p/399258#M19462</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-09-27T16:38:36Z</dc:date>
    </item>
  </channel>
</rss>

