I need to control the data type when reading XML data in SAS. The XML data are written and accessed using the XML libname engine in SAS.
SAS seems to guess the data type based on the contents of a column: If I write "20081002" to my XML data in a character column, it will be read back in as a numerical variable.
An example:
filename my_xml '/tmp/my.xml'; * Yes, I use SAS on Unix *;
libname my_xml XML;
data my_xml.data_type_test;
text_char="This is obviously text";
date_char="20081002";
num_char="42";
genuine_num=42;
run;
proc copy inlib=my_xml outlib=WORK;
run;
libname my_xml;
filename my_xml CLEAR;
Only the last column is defined as numerical data type in the XML data, but when I copy it into my WORK library, only the column text_char is character. The other 3 are now numeric.
How can I control the data type when reading XML data in SAS?