BookmarkSubscribeRSS Feed
Marius07
Calcite | Level 5

Hi all,

 

I am trying to import XML files into SAS. In order to do this I used the XML Mapper to create a code for importing the data. Which is the following:

 

/********************************************************************************
* Generated by XML Mapper, 903000.0.0.20110518190000_v930
********************************************************************************/
DM "log; clear;";
DM "output; clear;";
/*
* Environment
*/
filename SPNAMEYY 'M:\Marius\Rating_Data\SP-ABCP-2022-06-01\SP-NAME-YY113389019-Royal-Park-Investments-Funding-Corp--2022-06-01-ISSUER.xml';
filename SXLEMAP 'M:\Marius\Rating_Data\map1.map';
libname SPNAMEYY xmlv2 xmlmap=SXLEMAP access=READONLY;

/*
* Catalog
*/

proc datasets lib=SPNAMEYY; run;

/*
* Contents
*/

proc contents data=SPNAMEYY.xbrl varnum; run;
proc contents data=SPNAMEYY.schemaRef varnum; run;
proc contents data=SPNAMEYY.context varnum; run;
proc contents data=SPNAMEYY.entity varnum; run;
proc contents data=SPNAMEYY.identifier varnum; run;
proc contents data=SPNAMEYY.period varnum; run;
proc contents data=SPNAMEYY.ROCRA varnum; run;
proc contents data=SPNAMEYY.RAN varnum; run;
proc contents data=SPNAMEYY.FCD varnum; run;
proc contents data=SPNAMEYY.ISD varnum; run;
proc contents data=SPNAMEYY.SSC varnum; run;
proc contents data=SPNAMEYY.ISSNAME varnum; run;
proc contents data=SPNAMEYY.ISI varnum; run;
proc contents data=SPNAMEYY.ISIS varnum; run;
proc contents data=SPNAMEYY.IND varnum; run;
proc contents data=SPNAMEYY.OBT varnum; run;
proc contents data=SPNAMEYY.INSTNAME varnum; run;
proc contents data=SPNAMEYY.INI varnum; run;
proc contents data=SPNAMEYY.INIS varnum; run;
proc contents data=SPNAMEYY.INRD varnum; run;
proc contents data=SPNAMEYY.IP varnum; run;
proc contents data=SPNAMEYY.R varnum; run;
proc contents data=SPNAMEYY.RAD varnum; run;
proc contents data=SPNAMEYY.RAC varnum; run;
proc contents data=SPNAMEYY.WST varnum; run;
proc contents data=SPNAMEYY.ROL varnum; run;
proc contents data=SPNAMEYY.OAN varnum; run;
proc contents data=SPNAMEYY.RT varnum; run;
proc contents data=SPNAMEYY.RST varnum; run;
proc contents data=SPNAMEYY.RTT varnum; run;

/*
* Printing
*/

title 'Table xbrl';
proc print data=SPNAMEYY.xbrl; run;
title;

title 'Table schemaRef';
proc print data=SPNAMEYY.schemaRef; run;
title;

title 'Table context';
proc print data=SPNAMEYY.context; run;
title;

title 'Table entity';
proc print data=SPNAMEYY.entity; run;
title;

title 'Table identifier';
proc print data=SPNAMEYY.identifier; run;
title;

title 'Table period';
proc print data=SPNAMEYY.period; run;
title;

title 'Table ROCRA';
proc print data=SPNAMEYY.ROCRA; run;
title;

title 'Table RAN';
proc print data=SPNAMEYY.RAN; run;
title;

title 'Table FCD';
proc print data=SPNAMEYY.FCD; run;
title;

title 'Table ISD';
proc print data=SPNAMEYY.ISD; run;
title;

title 'Table SSC';
proc print data=SPNAMEYY.SSC; run;
title;

title 'Table ISSNAME';
proc print data=SPNAMEYY.ISSNAME; run;
title;

title 'Table ISI';
proc print data=SPNAMEYY.ISI; run;
title;

title 'Table ISIS';
proc print data=SPNAMEYY.ISIS; run;
title;

title 'Table IND';
proc print data=SPNAMEYY.IND; run;
title;

title 'Table OBT';
proc print data=SPNAMEYY.OBT; run;
title;

title 'Table INSTNAME';
proc print data=SPNAMEYY.INSTNAME; run;
title;

title 'Table INI';
proc print data=SPNAMEYY.INI; run;
title;

title 'Table INIS';
proc print data=SPNAMEYY.INIS; run;
title;

title 'Table INRD';
proc print data=SPNAMEYY.INRD; run;
title;

title 'Table IP';
proc print data=SPNAMEYY.IP; run;
title;

title 'Table R';
proc print data=SPNAMEYY.R; run;
title;

title 'Table RAD';
proc print data=SPNAMEYY.RAD; run;
title;

title 'Table RAC';
proc print data=SPNAMEYY.RAC; run;
title;

title 'Table WST';
proc print data=SPNAMEYY.WST; run;
title;

title 'Table ROL';
proc print data=SPNAMEYY.ROL; run;
title;

title 'Table OAN';
proc print data=SPNAMEYY.OAN; run;
title;

title 'Table RT';
proc print data=SPNAMEYY.RT; run;
title;

title 'Table RST';
proc print data=SPNAMEYY.RST; run;
title;

title 'Table RTT';
proc print data=SPNAMEYY.RTT; run;
title;


/*
* Local Extraction
*/

DATA xbrl; SET SPNAMEYY.xbrl; run;
DATA schemaRef; SET SPNAMEYY.schemaRef; run;
DATA context; SET SPNAMEYY.context; run;
DATA entity; SET SPNAMEYY.entity; run;
DATA identifier; SET SPNAMEYY.identifier; run;
DATA period; SET SPNAMEYY.period; run;
DATA ROCRA; SET SPNAMEYY.ROCRA; run;
DATA RAN; SET SPNAMEYY.RAN; run;
DATA FCD; SET SPNAMEYY.FCD; run;
DATA ISD; SET SPNAMEYY.ISD; run;
DATA SSC; SET SPNAMEYY.SSC; run;
DATA ISSNAME; SET SPNAMEYY.ISSNAME; run;
DATA ISI; SET SPNAMEYY.ISI; run;
DATA ISIS; SET SPNAMEYY.ISIS; run;
DATA IND; SET SPNAMEYY.IND; run;
DATA OBT; SET SPNAMEYY.OBT; run;
DATA INSTNAME; SET SPNAMEYY.INSTNAME; run;
DATA INI; SET SPNAMEYY.INI; run;
DATA INIS; SET SPNAMEYY.INIS; run;
DATA INRD; SET SPNAMEYY.INRD; run;
DATA IP; SET SPNAMEYY.IP; run;
DATA R; SET SPNAMEYY.R; run;
DATA RAD; SET SPNAMEYY.RAD; run;
DATA RAC; SET SPNAMEYY.RAC; run;
DATA WST; SET SPNAMEYY.WST; run;
DATA ROL; SET SPNAMEYY.ROL; run;
DATA OAN; SET SPNAMEYY.OAN; run;
DATA RT; SET SPNAMEYY.RT; run;
DATA RST; SET SPNAMEYY.RST; run;
DATA RTT; SET SPNAMEYY.RTT; run;

 

However, when I try to run the code I get the following error message:

 

9 filename SPNAMEYY
9 ! 'M:\Marius\Rating_Data\SP-ABCP-2022-06-01\SP-NAME-YY113389019-Royal-Park-Investments-Funding-
9 ! Corp--2022-06-01-ISSUER.xml';
10 filename SXLEMAP 'M:\Marius\Rating_Data\map1.map';
11 libname SPNAMEYY xmlv2 xmlmap=SXLEMAP access=READONLY;
NOTE: Processing XMLMap version 2.1.
ERROR: Xpath construct
/{http://www.xbrl.org/2003/instance}xbrl/{http://www.xbrl.org/2003/instance}ROCRA/{http://www.xbrl
.org/2003/instance}RAN for column RAN is an invalid, unrecognized, or unsupported form.

ERROR: Error in the LIBNAME statement.

 

The XML file, which I try to import is attached. 

 

Bonus question: Does anybody has an idea how I can automate this procedure so that I can read in approx. 70.000 XML files containing similar information?

 

Thank you very much and kind regards

Marius

 

3 REPLIES 3
AMSAS
SAS Super FREQ

Short answer
Yes you can probably automate it with a macro and using the "D Functions"

DOPEN Function 

Tom
Super User Tom
Super User

Did you make a MAP for this file type?  You did not share it.

Do you really expect to make dozens of datasets from that single file with only 68 lines?

Why?

RacheLGomez123
Fluorite | Level 6

LIBNAME statement to be "globally" assigned, either think about putting your LIBNAME statements into either an AUTOEXEC file on the server -- that will be invoked every time SAS starts up. OR, have each of your jobs use a %INCLUDE to include the file with your LIBNAME statements so you know it is available before the rest of your code runs. If these are metadata libraries and you want the security of the BI Platform, then use the META form of the LIBNAME statement (your libraries and tables will need to be registered in the metadata for you to use the META engine).

 

Regards,

Rachel Gomez

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 437 views
  • 1 like
  • 4 in conversation