Issue importing a huge zipped text 'file.txt.gz'. Tried 'gzip -c filepath'.

Reply
New Contributor
Posts: 3

Issue importing a huge zipped text 'file.txt.gz'. Tried 'gzip -c filepath'.

Could not import a huge text file zipped as 'file.txt.gz'.

Tried "filename file_ref Pipe 'gzip -c filepath';" and getting "ERROR: Invalid device type." while trying to read it using infile and input statements(Data Step).

 

Any help is Appreciated!

 

Esteemed Advisor
Posts: 6,713

Re: Issue importing a huge zipped text 'file.txt.gz'. Tried 'gzip -c filepath'.

When decompressing to stdout, use

gzip -dc filename
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
New Contributor
Posts: 3

Re: Issue importing a huge zipped text 'file.txt.gz'. Tried 'gzip -c filepath'.

 

Appreciate your response!

 

I tried that too, still same issue.

 

 

 

 

Esteemed Advisor
Posts: 6,713

Re: Issue importing a huge zipped text 'file.txt.gz'. Tried 'gzip -c filepath'.

Do you have XCMD enabled? Run

proc options;
run;

and search for "XCMD" in the log.

filename pipe only works when XCMD is enabled.

 

But you can try filename zip:

filename lgcy_gz zip "/product/....../infile.txt.gz";

 

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
New Contributor
Posts: 3

Re: Issue importing a huge zipped text 'file.txt.gz'. Tried 'gzip -c filepath'.

[ Edited ]

Ran Proc Options and i could see 'XCMD' in the log.

 

Tried (FILENAME LGCY_GZ ZIP "/product/sas-shared/...../file.txt.gz" lrecl=32767Smiley Wink getting the error below.

 

ERROR: The file "/product/sas-shared/......./TWC_LEGACY1.TXT.gz" exists and is not a zip file. The output
file must be a zip file.

Respected Advisor
Posts: 3,840

Re: Issue importing a huge zipped text 'file.txt.gz'. Tried 'gzip -c filepath'.

[ Edited ]

@Ram_Bravos

Unlike in your previous post you're now trying to use the ZIP engine. For this to work you would need a ZIP and not a GZ archive. 

Stick to the PIPE.

 

First thing to do: Use Putty or the like and make your GZIP command work without any SAS involvement. Once that works stick the command into pipe using the SAS Filename command as you've already started doing.

FILENAME LGCY_GZ PIPE "gzip -dc /product/..../Infile.TXT.gz" lrecl=32767;

 

Make sure you're using a length for lrecl long enough for the file you want to read (infile.txt). lrecl may be longer than 32767.

 

And for a first test using SAS I'd go for code as below:

filename lgcy_gz pipe "gzip -dc /product/..../infile.txt.gz" lrecl=32767;
data legacy_test;
  infile lgcy_gz;
  input;
  put _infile_;
  stop;
run;
Esteemed Advisor
Posts: 6,713

Re: Issue importing a huge zipped text 'file.txt.gz'. Tried 'gzip -c filepath'.


Ram_Bravos wrote:

Ran Proc Options and i could see 'XCMD' in the log.

 

Tried (FILENAME LGCY_GZ ZIP "/product/sas-shared/...../file.txt.gz" lrecl=32767Smiley Wink getting the error below.

 

ERROR: The file "/product/sas-shared/......./TWC_LEGACY1.TXT.gz" exists and is not a zip file. The output
file must be a zip file.


So you are forced to use the external gzip.

 

Do this:

filename oscmd pipe "gzip -d /product/..../Infile.TXT.gz 2>&1";

data _null_;
infile oscmd;
input;
put _infile_;
run;

filename oscmd clear;

You will see all messages created by the system call in your SAS log.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 6 replies
  • 117 views
  • 0 likes
  • 3 in conversation