BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
FriedEgg
SAS Employee

.tar.gz is more commonly know as a tarball.  It is the result of using the tar utility and gzip.  I could be incorrect but gzip alone should not be able to unpack this file, unless that is a unique feature of the program in windows vrs. unix.  I would think you would need to use an alternative application such as winzip or 7-zip to handle this file as I do not this there is a dos port for tar.  Once extracted you need to setup a program that will gather the file names from the extracted archive and then read those files.  There are plenty of examples that show how to do this around the web, including on this forum. 

Here is a link to one such paper:

Using FILEVAR= to read multiple external files in a DATA Step http://support.sas.com/techsup/technote/ts581.pdf

paulacalazans
Calcite | Level 5

HI all,

I tried to apply the code you sent but first I downloaded the Gzip:

Gzip for Windows => downloaded: Complete package, except sources


1) In  the command prompt:

                          "C:\Users\sbrpac>"C:\Program Files (x86)\GnuWin32\bin\gzip" -cd "C:\data.csv.gz"

Returned only the first row of the csv.

2) In SAS

                    %let File1="C:\data.csv.gz";

                    %let dir=C:\"Program Files (x86)"\GnuWin32\bin\gzip;

                    Data result_data ;

                         filename file2 pipe %unquote(%str(%'&dir -cd &file1%'));

                        infile file2 dlm="|" LRECL=32767 truncover  dsd firstobs=2;

                        ..... run;

Returned an empty table.

Do you know what might have been wrong?

Tom
Super User Tom
Super User

Two possibilities.

1) The  one line is the error message from GZIP telling you why it didn't work. Try this code and check the lines in the SAS log.:

filename file2 pipe %unquote(%str(%'&dir -cd &file1%'));

Data result_data ;

  infile file2 obs=2 ;

  input;

  put _infile_;

run;

2) The end of line characters for the CSV file do not match what your SAS session is looking for.

Try this to have SAS show you the first five lines.  Any non printable characters will cause SAS to list the hex codes for the characters in the line.


filename file2 pipe %unquote(%str(%'&dir -cd &file1%'));

Data result_data ;

  infile file2 obs=5 ;

  input;

  list;

run;


PS: You are working way too hard to manage the quotes in your OS commands. Use the QUOTE() function.


filename file2 pipe %sysfunc(quote(&dir -cd &file1));

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
  • 17 replies
  • 4656 views
  • 6 likes
  • 6 in conversation