Can you please motivate your requirement?
Are you referring to an external XML map or one that SAS maps?
A guess and likely not the most helpful if you have many files, but open the XML in a spreadsheet program. If the data looks "good" save to a CSV and import that perhaps with datastep code to set variable names as you would like.
Hi,
the XML file is not properly organised when I opened it as an excel file.
I am attaching the XML file for your reference.
Thanks,
Moovendhan Devaraj
Yes. Data step can do that . But that depend on how complicated the XML file is .
Or you could check xml2 engine. Like : libname x xml2 '......' automap=replace;
Let me try this, hope this works....
tried this soultion and sas throws an error as below,
ERROR 22-7: Invalid option name AUTOMAP.
I am using sas version 9.3 in my windows PC. does this option work for you, or is it used in some different version of SAS.
The AUTOMAP option was not available in the XMLV2 LIBNAME engine until the second maintenance release of SAS 9.3. Based on the error message, I suspect you are not at that maintenance level of SAS 9.3.
you are correct, I am using sas 9.3. Probably not that version that has auto map option.
Is there any way that I can have that enabled in the current version of SAS, is there any path that needs to be installed to enable this.
Sorry for the confusion,
I should have given more specific requirment.
I have zipped and attached an example XML, and this needs to be imported without an XML map.
I have to automate this in such a way that any xml file that is been provided needs to be imported without any issue.
The column names would change with different XML files.
Kindly help.
OK. Here is .
libname nhl xmlv2 '/folders/myfolders/LabReviewMicroSampleData.xml'
automap=replace
xmlmap='/folders/myfolders/NhlGenerate.map';
proc contents data=nhl._all_ nodetails;
run;
proc print data=nhl.Sex;run;
Hi Xia,
In this solution you have used 'nhlgenerate.map' import the data form the XML file.
Is there any way that we can import the data without any XML map been created?
When I tried creating a xml map using XML automap, I getting error due to unavailability of formats and informats. Is it possible for you to share the map, that you used?
xmlmap='/folders/myfolders/NhlGenerate.map';
is genereated by SAS . You can assign it any name like x.map yy.map . No need to consider about it.
If you SAS doesn't has such ability ,try SAS University Edition.
As noted, the easiest way to do this is with the XMLV2 LIBNAME engine and the AUTOMAP option. By using AUTOMAP=REPLACE, the map file is regenerated each time and is specific to the XML file specified. If you don't like the idea of keeping the map file around between runs, you can automatically throw it away by using a temporary map file:
filename test 'c:\LabReviewMicroSampleData.xml'; filename tempmap temp; libname test xmlv2 xmlmap=tempmap automap=replace;
I had no problems using this method to create data sets from your posted XML file.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.