11-11-2014 06:09 AM
Does anyone know if it is possible to combine multiple datasets when exporting to a single XML file?
The specific example I have in mind is as follows:
1. Required XML Logical structure
Our customers can have one or more accounts and can belong to one or more customer groups, so the structure of XML that I need to create is one record per customer and multiple sub-records at the same hierarchical level for each account and customer group, i.e. something like the following:
...other customer attributes...
<subrecord - account>
<subrecord - account>
<subrecord - customer type>
...customer type attributes...
2. Current SAS data structures
Currently the data that I need to build the XML from is stored in 3 tables.
a) Customer which is keyed on customer_id.
b) Customer_accounts which is keyed on customer_id and account_id
c) Customer_types which is keyed on customer_id and cust_type_id.
I can build the required XML file in an old school way by using a data step that incorporates a set statement for each of the (sorted) tables listed above with multiple put statements. However, even though this works I am wondering whether there is a more efficient (i.e faster in elapsed time) way to do this using the XML engine or other more recently developed SAS tool.
After searching online I've not found any examples of XML exports that use multiple tables. If I can only use a single dataset then this implies that I have to restructure the input data by merging into a single table that has duplicate customer (and potentially account) values across multiple records. Can I configure the XML hierachy to create the multiple sub-record types that I will need?
Apologies if this hasn't been posted to the correct community - I wasn't sure of the most appropriate place.
Thanks in advance.
11-11-2014 06:35 AM
Well, my first answer would have been code it by hand as you have full functionality then, but I see reading down you already know that. The only other thing I can think of is to write a tagset. Right click on Results in the results window and select templates. Then navigate to Excelbase for instance and you can see the one developed for Export To ExcelXP. However its a fair bit of work, so if its just for a one off, your probably better with the put statements.
11-11-2014 06:59 AM
tagsets.excelxp, for instance, can put the results of several steps into one xml file.
If you want a customized xml structure, you will need a fitting tagset, or you do it by hand in a data step. And I don't think you can beat a properly written data step, timewise.