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.
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-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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