<?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: Reading XML resulting dataset has datetime variable as missing value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-XML-resulting-dataset-has-datetime-variable-as-missing/m-p/10894#M938</link>
    <description>Hi Cynthia,&lt;BR /&gt;
I am using XML mapper. It works fine if we do not use the XML map</description>
    <pubDate>Tue, 27 Apr 2010 20:23:47 GMT</pubDate>
    <dc:creator>anandbillava</dc:creator>
    <dc:date>2010-04-27T20:23:47Z</dc:date>
    <item>
      <title>Reading XML resulting dataset has datetime variable as missing value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-XML-resulting-dataset-has-datetime-variable-as-missing/m-p/10892#M936</link>
      <description>I have writen a program for SAS to xml conversion and xml to sas conversion.&lt;BR /&gt;
There is a variable which is datetime variable with format ddmmyy10.&lt;BR /&gt;
Converstion of this dataset to xml works fine and the values stored as below&lt;BR /&gt;
  &lt;DOB&gt;1943-12-11&lt;/DOB&gt;&lt;BR /&gt;
&lt;BR /&gt;
But while reading back this XML to SAS dataset the datetime variables are converted as missing value.&lt;BR /&gt;
&lt;BR /&gt;
libname out xml 'C:\temp.xml';&lt;BR /&gt;
&lt;BR /&gt;
data out.temp;&lt;BR /&gt;
set temp;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Reading back to XML&lt;BR /&gt;
&lt;BR /&gt;
libname in xml 'C:\temp.xml';&lt;BR /&gt;
data temp;&lt;BR /&gt;
set in.temp;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The resulting dataset has datetime varialbe as missing values.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
libname out xml 'C:\temp.xml';&lt;BR /&gt;
&lt;BR /&gt;
It does work when i set the datetime variable to is8601da10 format while converting it to XML. Conversion back from XML does not require any change in code.&lt;BR /&gt;
&lt;BR /&gt;
format xfer_date is8601da10.;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
But I have lot of datasets and I am wrting a dynamic program which converts all the sas datasets at one shot to different xml files. &lt;BR /&gt;
So I am not sure which are all the datetime formats there in the sas dataset.&lt;BR /&gt;
&lt;BR /&gt;
Is there a way to set the sas date format globally to is8601da10 format.?&lt;BR /&gt;
Or is there any better solution for this ?</description>
      <pubDate>Tue, 27 Apr 2010 17:13:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-XML-resulting-dataset-has-datetime-variable-as-missing/m-p/10892#M936</guid>
      <dc:creator>anandbillava</dc:creator>
      <dc:date>2010-04-27T17:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: Reading XML resulting dataset has datetime variable as missing value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-XML-resulting-dataset-has-datetime-variable-as-missing/m-p/10893#M937</link>
      <description>Hi:&lt;BR /&gt;
  When I create an XML file from a SAS dataset, like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
** make a SAS dataset with both date and datetime variables;&lt;BR /&gt;
data bday;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input name $ bdate : ddmmyy10. dtvar : datetime18.;&lt;BR /&gt;
format bdate ddmmyy10.;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
anne 15/11/1950  15nov1950:07:15:00&lt;BR /&gt;
bob  23/08/1951  23aug1951:10:23:00&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
            &lt;BR /&gt;
** Create XML file FROM SAS data;&lt;BR /&gt;
libname out xml 'C:\temp\outSAS.xml';&lt;BR /&gt;
                       &lt;BR /&gt;
data out.bday;&lt;BR /&gt;
set bday;&lt;BR /&gt;
run;&lt;BR /&gt;
         &lt;BR /&gt;
libname out clear;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                 &lt;BR /&gt;
This is the XML output file that I get:&lt;BR /&gt;
[pre]&lt;BR /&gt;
&amp;lt;?xml version="1.0" encoding="windows-1252" ?&amp;gt;&lt;BR /&gt;
&amp;lt;TABLE&amp;gt;&lt;BR /&gt;
   &amp;lt;BDAY&amp;gt;&lt;BR /&gt;
      &amp;lt;name&amp;gt; anne &amp;lt;/name&amp;gt;&lt;BR /&gt;
      &amp;lt;bdate&amp;gt; 1950-11-15 &amp;lt;/bdate&amp;gt;&lt;BR /&gt;
      &amp;lt;dtvar&amp;gt; -288031500 &amp;lt;/dtvar&amp;gt;&lt;BR /&gt;
   &amp;lt;/BDAY&amp;gt;&lt;BR /&gt;
   &amp;lt;BDAY&amp;gt;&lt;BR /&gt;
      &amp;lt;name&amp;gt; bob &amp;lt;/name&amp;gt;&lt;BR /&gt;
      &amp;lt;bdate&amp;gt; 1951-08-23 &amp;lt;/bdate&amp;gt;&lt;BR /&gt;
      &amp;lt;dtvar&amp;gt; -263741820 &amp;lt;/dtvar&amp;gt;&lt;BR /&gt;
   &amp;lt;/BDAY&amp;gt;&lt;BR /&gt;
&amp;lt;/TABLE&amp;gt;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                             &lt;BR /&gt;
When I use this code to READ the XML file back into a SAS dataset (without making any changes to the code):&lt;BR /&gt;
[pre]&lt;BR /&gt;
**Reading XML data back into SAS;&lt;BR /&gt;
                     &lt;BR /&gt;
libname in xml 'C:\temp\outSAS.xml';&lt;BR /&gt;
data work.bday_fromxml;&lt;BR /&gt;
set in.bday;&lt;BR /&gt;
run;&lt;BR /&gt;
               &lt;BR /&gt;
proc print data=work.bday_fromxml;&lt;BR /&gt;
  format bdate ddmmyy10. dtvar datetime18.;&lt;BR /&gt;
run;&lt;BR /&gt;
              &lt;BR /&gt;
libname in clear;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
  &lt;BR /&gt;
This is my resulting PROC PRINT output (neither of my variables for date or datetime are missing):&lt;BR /&gt;
[pre]&lt;BR /&gt;
Obs                 DTVAR         BDATE    NAME&lt;BR /&gt;
                                                        &lt;BR /&gt;
 1       15NOV50:07:15:00    15/11/1950    anne&lt;BR /&gt;
 2       23AUG51:10:23:00    23/08/1951    bob&lt;BR /&gt;
                       &lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                                    &lt;BR /&gt;
I ran the code in SAS 9.2...if you are having issues using the SAS XML Libname Engine, you might want to refer to the documentation. I believe that in SAS 8.2, you did need to have dates in ISO format, but that is no longer the case. I'm not sure when the date handling changed. You might with to work with Tech Support on this question. To open a track with Tech Support, go to:&lt;BR /&gt;
&lt;A href="http://support.sas.com/ctx/supportform/createForm" target="_blank"&gt;http://support.sas.com/ctx/supportform/createForm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
cynthia</description>
      <pubDate>Tue, 27 Apr 2010 18:10:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-XML-resulting-dataset-has-datetime-variable-as-missing/m-p/10893#M937</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-04-27T18:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: Reading XML resulting dataset has datetime variable as missing value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-XML-resulting-dataset-has-datetime-variable-as-missing/m-p/10894#M938</link>
      <description>Hi Cynthia,&lt;BR /&gt;
I am using XML mapper. It works fine if we do not use the XML map</description>
      <pubDate>Tue, 27 Apr 2010 20:23:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-XML-resulting-dataset-has-datetime-variable-as-missing/m-p/10894#M938</guid>
      <dc:creator>anandbillava</dc:creator>
      <dc:date>2010-04-27T20:23:47Z</dc:date>
    </item>
    <item>
      <title>Re: Reading XML resulting dataset has datetime variable as missing value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-XML-resulting-dataset-has-datetime-variable-as-missing/m-p/10895#M939</link>
      <description>Hi:&lt;BR /&gt;
  You only need XML Mapper if your XML file is "non-standard" or heavily hierarchical or if you want to map the XML tags to particular column names (or vice versa) in SAS 9.2.&lt;BR /&gt;
 &lt;BR /&gt;
  I would still recommend that you work with Tech Support on this question.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Tue, 27 Apr 2010 21:06:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-XML-resulting-dataset-has-datetime-variable-as-missing/m-p/10895#M939</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-04-27T21:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: Reading XML resulting dataset has datetime variable as missing value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-XML-resulting-dataset-has-datetime-variable-as-missing/m-p/10896#M940</link>
      <description>I already posted it to tech support. Lets see what they have to say on it. Meanwhile I am keeping my try.</description>
      <pubDate>Wed, 28 Apr 2010 14:15:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-XML-resulting-dataset-has-datetime-variable-as-missing/m-p/10896#M940</guid>
      <dc:creator>anandbillava</dc:creator>
      <dc:date>2010-04-28T14:15:45Z</dc:date>
    </item>
  </channel>
</rss>

