SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
RealePrimavera
Obsidian | Level 7

Hello,

 

I have multiple xml.gz files in a folder and I have a macro to read multiple xml files to have some output in SAS dataset. However, I need to explicitly and manually extract those xml.gz to xml files before runnning them in a macro. 

 

I was wondering if there is an option where I can use gzip zip filename option along with xml filename option (SXLELIB). So, that I can directly read xml.gz files in the xml reading macro. 

 

  • For e.g. if I can add this option: 

filename fromzip ZIP "C:\Temp\Folder\data1.xml.gz" GZIP;   

 

  • to the below filename and libname statements of xml:

filename SXLELIB "C:\Folder\data1.xml";
filename SXLEMAP "C:\XMLMap\xmlmap.map";
libname SXLELIB xmlv2 xmlmap=SXLEMAP access=READONLY;

 

What do you think? (I see lot of solutions for directly reading .gz files by filename gzip zip option but not sure if can be combined with xml reader filename). 

 

Thank you already for reading it and giving a thought (if you do) 🙂 

 

Cheers!

 

1 ACCEPTED SOLUTION

Accepted Solutions
s_lassen
Meteorite | Level 14

I do not think you can combine the GZIP filename with the XML libname in a meaningful way.

 

Meaning that you will have to extract the file from the gz archive before assigning it to a libname, e.g.

filename fromzip ZIP "C:\Temp\Folder\data1.xml.gz" GZIP;   

filename tempxml temp;
data _null_;
  rc=fcopy('fromzip','tempxml');
  call symputx('temppath',pathname('tempxml'));
run;
filename SXLEMAP "C:\XMLMap\xmlmap.map";libname SXLELIB xml "&temppath" xmlmap=SXLEMAP access=READONLY;

View solution in original post

2 REPLIES 2
s_lassen
Meteorite | Level 14

I do not think you can combine the GZIP filename with the XML libname in a meaningful way.

 

Meaning that you will have to extract the file from the gz archive before assigning it to a libname, e.g.

filename fromzip ZIP "C:\Temp\Folder\data1.xml.gz" GZIP;   

filename tempxml temp;
data _null_;
  rc=fcopy('fromzip','tempxml');
  call symputx('temppath',pathname('tempxml'));
run;
filename SXLEMAP "C:\XMLMap\xmlmap.map";libname SXLELIB xml "&temppath" xmlmap=SXLEMAP access=READONLY;

RealePrimavera
Obsidian | Level 7

Thanks @s_lassen !!! This is what something similar I was looking for but without the clue that filerefs can be copied. 

Cheers!

sas-innovate-white.png

Special offer for SAS Communities members

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.

 

View the full agenda.

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 4088 views
  • 1 like
  • 2 in conversation