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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: