Dear Folk,
I have a requirement to read a text file(.sas code file) and save in to MS SQL server DB table(complete file in xml object column)by converting to xml format.
As of now I can create XML file on disk by SAS program and I can connect to MS SQL serve for DB transactions.
But here challenges in step wise way(all in SAS code) are ,
1) Read text file via SAS - Done
2) Convert aboveto xml object (not file) - How to do ?
3) Save this object to MS SQL DB - How to do ?
Requesting to please have the suggestions.
Regards,
Tushar Jain
Define "XML object". For me a XML object (see DOM) is either a data island, a tree or a node.
I am assuming SAS will have xml object like DB or C#.
If not, then by using SAS code how can we insert the complete file (by reading from disk) in to MS sql database(pass-through or lib name) ?
SAS has two data types: character and numeric. Since XML is text, you can store it in a character variable, provided that the XML in question does not exceed 32767 characters.
You are going to have a problem moving a complete SAS program file (which could be thousands of lines long) into a single XML "object" in the server. SAS has a 32K limit on the size of character variable.
So either move the original file line by line into an SQL server table and have the database transform it into an XML object.
Or move the XML file line by line into the SQL server and have the server combine the lines into a single blob/clob or whatever they use to store XML.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.