Hi,
I am using XML Mapper engine xmlv2. I am using a map to load 2 or more XML files. I would like to modify the map to have the file name as one of the variables. Any knows how can I get the filenames as part of the variables in my dataset?
This is unclear. Please give an example of want you want.
Are you asking if there is a way in your map file to specify that when you use it to convert an XML file to a SAS dataset that the name of the XML being converted? I would be very surprised if that is possible as why would the map file know anything about the source of the file that it is being used to parse?
You could do that in separate logic. Let's setup an example by creating an XML file.
libname out xmlv2 'c:\downloads\class1.xml';
data out.class; set sashelp.class; run;
libname out clear;
Now let's read that back into a SAS dataset and use the PATHNAME() function to find the path that the libref being used.
libname in xmlv2 'c:\downloads\class1.xml';
data class;
set in.class ;
filename=pathname('in');
run;
Results:
Obs Name Sex Age Height Weight filename 1 Alfred M 14 69 112.5 c:\downloads\class1.xml 2 Alice F 13 56.5 84 c:\downloads\class1.xml 3 Barbara F 13 65.3 98 c:\downloads\class1.xml 4 Carol F 14 62.8 102.5 c:\downloads\class1.xml 5 Henry M 14 63.5 102.5 c:\downloads\class1.xml 6 James M 12 57.3 83 c:\downloads\class1.xml 7 Jane F 12 59.8 84.5 c:\downloads\class1.xml 8 Janet F 15 62.5 112.5 c:\downloads\class1.xml 9 Jeffrey M 13 62.5 84 c:\downloads\class1.xml 10 John M 12 59 99.5 c:\downloads\class1.xml 11 Joyce F 11 51.3 50.5 c:\downloads\class1.xml 12 Judy F 14 64.3 90 c:\downloads\class1.xml 13 Louise F 12 56.3 77 c:\downloads\class1.xml 14 Mary F 15 66.5 112 c:\downloads\class1.xml 15 Philip M 16 72 150 c:\downloads\class1.xml 16 Robert M 12 64.8 128 c:\downloads\class1.xml 17 Ronald M 15 67 133 c:\downloads\class1.xml 18 Thomas M 11 57.5 85 c:\downloads\class1.xml 19 William M 15 66.5 112 c:\downloads\class1.xml
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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: