Desktop productivity for business analysts and programmers

XML import to SAS data set from SQL database

Reply
Occasional Contributor
Posts: 5

XML import to SAS data set from SQL database

Hi Everyone,

I have been searching the net with no luck and thought i would try here.

We use some SOA services and as a result customer information is stored to an XML file in a SQL database a customer level.

i have had no joy in finding how to import multiple records from an SQL DB.

Has any one had any exprience doing this i.e pulling in multiple XML files to a single sas dataset?

Any assistance would be greatly appreciated.
Community Manager
Posts: 2,889

Re: XML import to SAS data set from SQL database

You can use the XML library engine in SAS to read XML as data. Use SAS XML Mapper to create a map file (schema rules) for how to interpret the XML you're reading.

You'll have to do this for each XML source you're working with, and then use DATA step or SQL to merge the multiple result tables together.

Here's an example of using the XML library engine:

http://blogs.sas.com/sasdummy/index.php?/archives/55-Mining-the-VP-debate-results-according-to-Twitt...

Chris
Occasional Contributor
Posts: 5

Re: XML import to SAS data set from SQL database

Thanks Chris - I really appreciate your reply.


The XML Map and XML libname engine is the second part of the project. I almost have this covered, the link you provided is a great help and confirms I am on the right track.

The major issue I have is the XML data is being stored into a SQL database which I access through SAS via an ODBC Connection with the XML being quite complex + more than 1024bytes + multiple XML with different mappings.

My temporary solution so far is to use the SQL pass through to call a stored procedure (with SAS macro to pass through variables needed).

The stored procedure then uses BCP to save the XML files on my network.

Then it moves on the to the second stage that you have pointed out.

I am still in the testing stage and will post the solution when i am happy with the results.
Ask a Question
Discussion stats
  • 2 replies
  • 225 views
  • 0 likes
  • 2 in conversation