02-04-2014 03:03 PM
I am trying to output the data into XML. I am using the code
which is in the attached XML code.docxsas. I get the output as shown in the
attached Tstg.txt. Actually, I copied the output from browser and pasted in the
txt file. But I actually need the output as shown in Tstg-expected.txt file. I
am using 'SAS ENTERPRISE GUIDE 5.1'. Here are the issues:
For eg: In the tstg.txt file there is repeated level for
'includedcompany' with the same COMP_ID value '10000', but I need only those
distinct 'includedcompany' levels with COMP_ID value '10000' and '20000' (you
can see this in the tstg-expected.txt file)
Similarly, there is a repeating level of 'includedmember'
for the same IDS value of '1234567' in the tstg.txt file, which I do not need in
the output either.
4.I also need to output the labels of variables in the
output rather than variable names, I want to do this because there are some
variable names whose length is greater than 32, for eg
'TotalcountOfPeriodsForIncludedMembers'. I cannot output this name as column
name so I use it as a label instead and trying to output it.
well, I have a template for this to output the labels of
variables in XML output instead of names. Here it is
define tagset tagsets.uselabs;
NOTES "USE LABEL INSTEAD OF NAME FOR TAGS";
DEFINE EVENT SASCOLUMN;
put TEXT / if cmp(XMLDATAFORM, "ATTRIBUTE");
put ' name="' / if cmp(XMLDATAFORM,
put '"' / if cmp(XMLDATAFORM, "ATTRIBUTE");
xdent / if exist (MISSING);
break / if exist(MISSING);
put ' / >' / if cmp(XMLDATAFORM, "ATTRIBUTE");
put CR / if cmp(XMLDATAFORM, "ATTRIBUTE");
xdent / if cmp(XMLDATAFORM, "ATTRIBUTE");
break / if cmp(XMLDATAFORM, "ATTRIBUTE");
But, I cannot use this template above and the other one which is in the attached code at once. I
can only use either of them. So best I could do it is to insert this tagset
above into the already existing template 'tagsets.custom' which is in the
attached XML code sas. I have no idea how to do that as I am not an expert in
writing customized tagsets.
5. And finally I need that ns1: to go in the tag like '<ns1:includedMemberPeriods>'
in my output. When I tried to do that the code doesn't show any error but the
The operation completed successfully. Error processing
6. "Note: SAS variable labels, formats, and lengths are not written to DBMS tables."
This note appears in the log, how can I write SAS variable labels, formats, and lengths into DBMS tables?
So if somebody could help me out in resolving these issue or any ideas in doing so are highly appreciated
02-04-2014 11:56 PM
Do you have a schema for the valid XML that you need to generate? It looks like you are using the XML Libname Engine? The code that you attached looks like the type of template you might need to write back in SAS 9.1 -- before the XML Libname engine could use a schema with the XML Mapper to make you a map file. So, depending on the version of SAS you have, you might not need a custom tagset template. If so, the XML might be able to be generated using the standard XML Libname engine and an XML Map file. You are correct that you can only use one tagset template at a time in one ODS invocation statement or XML LIBNAME engine statement.
Have you looked at or tried to use the XML Mapper tool?
My recommendation is that you open a track with Tech Support. There are a lot of factors involved in generating your custom XML.
11-05-2014 03:24 PM
It's been a while on this post. Thank you very much on your feedback. I've generated the desired XML file by writing the customized template. Though I 've the XSDs provided on this, I did not use them at all. Can you tell me how is it different generating a XML file using the tagset and the XSD schema, when the XML file generated still follows the desired structure and datatype. Is it necessary to use the XSD files.
11-05-2014 03:53 PM
If you do have an XSD file and you are using SAS 9.2 or higher, the XML Libname Engine can read the XSD file and generate the appropriate map file to both import and export to/from XML. In SAS 9.1.3, when you needed to export from SAS to an XML format, there was no way for the XML Mapper to read the XSD file, and so you needed to write your own template to generate the tags with the proper structure. The purpose of an XSD file is to provide the structure information to the application that is going to read (or write) the XML file. In SAS 9.1.3, the XML Mapper read the XML and built a map file. Starting with SAS 9.2, the XML Mapper application could read either an XML file or an XSD file to build the map.
There is no absolute answer to your question. It is not necessary to use the XSD file. But it might be easier if you did. It is up to you.
11-06-2014 08:34 AM
Your response is very helpful. I tried using the XML libname engine to create a map file from the XSD I have in order to generate a XML file. But the map file looks very weird, it didn't read the column names I need in XML. Please find the attached XSD (File1) and the created map file (MapICr). I am also attaching my sample XML file(expectedFile) required to be generated. I am on SAS 9.4. Please help me out on why map looks different and what needs to be done to resolve the issue.
11-06-2014 02:07 PM
I am teaching and unable to do much more than post programs that have already been written or answer quick questions. If you need help with a specific problem, opening a track with Tech Support would be better, as they can refer your question to someone who is familiar with the XML Mapper in SAS 9.4.