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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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