DATA Step, Macro, Functions and more

Gzip Readin

Reply
Occasional Contributor
Posts: 8

Gzip Readin

I am trying to read a pipe delimited file from gzip into SAS. I have used the below code.

 

x "cd C:\Program Files (x86)\GnuWin32\bin"; /* to enable to run gzip command*/

 

FILENAME READER PIPE "gzip -cd &PATH.\Rawdata\File.gz";

 

DATA &LIB..&DSN. (COMPRESS=YES) ;
INFILE READER DELIMITER = '|' TRUNCOVER DSD LRECL=32767 FIRSTOBS=1 OBS=10;

 

There is a command prompt window showing up and unless i close it, the program isn't running further. Is there any way to close the cmd windows closes automatically or is there any way to stop this window coming up?

Super User
Super User
Posts: 9,409

Re: Gzip Readin

Posted in reply to Konakanchi

options noxwait:

http://support.sas.com/documentation/cdl/en/hostwin/69955/HTML/default/viewer.htm#n0xwt90ik8vxdrn137...

 

Do please avoid coding all in shouting case, it makes code hard to read, and you can use the code window - its the {i} above post are - so that essential code formatting is retained.

 

Occasional Contributor
Posts: 8

Re: Gzip Readin

I have used Options Noxwait; in the beginning of the program and don't see any changes. 

Super User
Super User
Posts: 9,409

Re: Gzip Readin

Posted in reply to Konakanchi

I would unzip the file before assigning it to a read.  So something like:

/* Send command to expand files */
x "C:\Program Files (x86)\GnuWin32\bin\gzip.exe -cd -f "c:\somewhere\Rawdata\File.gz";

/* Now read in the extracted files */
data want;
  infile "c:\somewhere\Rawdata\thefile.txt" dlm="|" truncover dsd lrecl=32767;
  input ...;
run;

Your code seems to be reading the command line rather than actually expanding the data then reading a file, which may also be the root of your problem.  I.e. you don't push piped command line strings directly into a read, infile expects a file, not an action.  

Super User
Posts: 9,886

Re: Gzip Readin

Posted in reply to Konakanchi

After you close the window, do you get the contents in your data step?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 4 replies
  • 79 views
  • 0 likes
  • 3 in conversation