BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BchBnz
Obsidian | Level 7

Hello everyone,

I am new to the community so handle with care :smileygrin:

I need some help importing data into SAS.

I am using compressed files and when I use SASZIPAM I end up having error messages "invalid data length"

So now I am trying to open them using PIPE command;

here is my code

FileName zipfile PIPE '7za e "c:\sas_data\my_notes\o_equities_20080528.tas.zip"

"o_equities_20080528.tas" -y -so';

Data dataset;

Infile zipfile dlm= ',' MISSOVER DSD firstobs=6;

input time  dum cpf  label  ED vol ba price;

run;

However I get this error message

Stderr output:

'7za' is not recognized as an internal or external command,

operable program or batch file

Please help;

Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Is your filename statement on 1 line or 2?

The following worked for me (in case it wraps, the entire filename statement is on one line):

FileName zipfile PIPE 'C:\Bch\7za.exe e "c:\sas_data\my_notes\o_equities_20080528.tas.zip" "o_equities_20080528.tas" -y -so';

Data datbase;

  infile zipfile dlm= ',' MISSOVER DSD firstobs=2;

  input name $ sex $ age height weight;

run;

View solution in original post

13 REPLIES 13
Tom
Super User Tom
Super User

Do you have the 7Zip program installed?  Is the search path set to include the directory where the 7za executable is?  If you do have it then perhaps all you need do is to add the path to the command.

filename zipfile PIPE '"c:\program files\somedirectory\7za.exe" e "c:\sas_data\my_notes\o_equities_20080528.tas.zip"

"o_equities_20080528.tas" -y -so';

BchBnz
Obsidian | Level 7

Thank you Tom,

I will try it now and let you know the outcome.

Thanks a lot!

BchBnz
Obsidian | Level 7

Hello Tom,

Sorry to bother you again but I have been trying with your solution and I always get this error message

Stderr output:

The filename, directory name, or volume label syntax is incorrect

This is the code I used;

FileName zipfile PIPE '"C:\Program Files\7-Zip\7z.exe" e "c:\sas_data\my_notes\o_equities_20080528.tas.zip"

"o_equities_20080528.tas" -y -so';

I don't understand the error here.

Many thanks

art297
Opal | Level 21

Is the program called 7z.exe or 7za.exe?  You have it shown the two different ways in your two posts.

BchBnz
Obsidian | Level 7

Hello Arthur,

In my 7-zip folder there are actually 3 .exe applications

7z.exe 7zG.exe and 7zFM.exe

I thought that 7za,exe and 7z.exe are both 7zip applications.

art297
Opal | Level 21

I was able to get it to work as follows:

1. Download the command line version of 7zip (i.e., 7za.exe) at:

http://downloads.sourceforge.net/sevenzip/7za920.zip

2. Copy and paste the four files into some directory (I put them in c:\art)

3. Run your code as you originally did.  I used:

filename zipfile PIPE 'c:\art\7za.exe e "c:\art\class.7z" "class.csv" -y -so';

data dataset;

  infile zipfile dlm= ',' MISSOVER DSD firstobs=2;

  input name $ sex $ age height weight;

run;

BchBnz
Obsidian | Level 7

Hello Arthur,

Here is the code following your useful advice,

FileName zipfile PIPE '"C:\Bch\7za.exe" e "c:\sas_data\my_notes\o_equities_20080528.tas.zip"

"o_equities_20080528.tas" -y -so';

Data dataset;

Infile zipfile dlm= ',' MISSOVER DSD firstobs=6;

input time  cpf $ label $ ID vol ba$ price;

run;

However I keep getting this output:

Stderr output:

The filename, directory name, or volume label syntax is incorrect

What am I doing wrong? Is it maybe the .tas file??


Sorry for the headache Smiley Happy

art297
Opal | Level 21

I don't think you need the double quotes around: "C:\Bch\7za.exe"

However, I don't think that is your real problem.  Are you sure that

c:\sas_data\my_notes\o_equities_20080528.tas.zip is the actual name of the zipped file and are you sure it contains the file:

o_equities_20080528.tas

art297
Opal | Level 21

Is your filename statement on 1 line or 2?

The following worked for me (in case it wraps, the entire filename statement is on one line):

FileName zipfile PIPE 'C:\Bch\7za.exe e "c:\sas_data\my_notes\o_equities_20080528.tas.zip" "o_equities_20080528.tas" -y -so';

Data datbase;

  infile zipfile dlm= ',' MISSOVER DSD firstobs=2;

  input name $ sex $ age height weight;

run;

BchBnz
Obsidian | Level 7

Indeed I did not need the double quote.

That solved this error

Stderr output:

The filename, directory name, or volume label syntax is incorrect

I am sure about the file names but I keep getting another error

Error:

cannot find archive

I am sure about the file location.

I am very thankful for your help, Arthur!

art297
Opal | Level 21

You marked the question as correct thus I'm not sure if you got your answer or not.

The code worked for me using the filenames you provided but, of course, I'm not running on your machine.

If it still isn't working, and you are submitting the entire filename statement on one line, then the only thing I can suggest is your getting a listing of the directory you are pointing to (which holds the archive) and quadruple check whether the entire path and archive name are correctly entered on your filename statement.

BchBnz
Obsidian | Level 7

The answer is correct for these error messages which were the main issue for me.

Stderr output:

'7za' is not recognized as an internal or external command,

operable program or batch file

Stderr output:

The filename, directory name, or volume label syntax is incorrect

I thank you for that! You are very helpful indeed.

I copy the path and the files names so I am sure about their location and names. I will try to have them on a separate folder with shorter paths and see if it works.


Many thanks.

BchBnz
Obsidian | Level 7

Dear Arthur,

It worked perfectly.

You were right. The file statement should be in 1 line not 2.

Thank you very much.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 13 replies
  • 21149 views
  • 3 likes
  • 3 in conversation