Previous Page | Next Page

Importing XML Documents

Importing an XML Document with Numeric Values

This example imports the XML document PRECISION.XML, which was exported in Exporting Numeric Values. This example illustrates how you can change the behavior for importing numeric values.

The first SAS program imports the XML document using the default behavior, which retrieves PCDATA from the element:

libname default xml 'C:\My Documents\precision.xml';

title 'Default Method';
proc print data=default.rawtest;
   format n_pi f14.10;
run;

The result of the import is the SAS data set DEFAULT.RAWTEST.

PROC PRINT of Data Set DEFAULT.RAWTEST

                          Default Method             1

                  Obs              N_PI           N

                    1      3.1400000000           1
                    2      6.2800000000           2
                    3      9.4200000000           3
                    4     12.5700000000           4
                    5     15.7100000000           5
                    6     18.8500000000           6
                    7     21.9900000000           7
                    8     25.1300000000           8
                    9     28.2700000000           9
                   10     31.4200000000          10

The second SAS program imports the XML document using the XMLDOUBLE= option in order to change the behavior, which retrieves the value from the rawdata= attribute in the element:

libname new xml 'C:\My Documents\precision.xml' xmldouble=internal;

title 'Precision Method';
proc print data=new.rawtest;
   format n_pi f14.10;
run;

The result of the import is SAS data set NEW.RAWTEST.

PROC PRINT of Data Set NEW.RAWTEST

                        Precision Method            2

                  Obs              N_PI           N

                    1      3.1415926536           1
                    2      6.2831853072           2
                    3      9.4247779608           3
                    4     12.5663706144           4
                    5     15.7079632679           5
                    6     18.8495559215           6
                    7     21.9911485751           7
                    8     25.1327412287           8
                    9     28.2743338823           9
                   10     31.4159265359          10

Previous Page | Next Page | Top of Page