BookmarkSubscribeRSS Feed
KevinViel
Pyrite | Level 9

I have used paths with embedded spaces before without issues while using pipes in SAS, but this one has me investigating more than I care on a Friday evening.  I have narrowed it down to the second path, by replacing the spaces with underscore and removing the double quotation marks.  Does anyone have a clue why?

 

309 filename _7zip

310 pipe

311 '"C:\Program Files\7-Zip\7z.exe" l "L:\SDTM\449\11444909\SAS Datasets (2017-02-10).zip"'

312 ;

313

314 data _null_ ;

315 infile _7zip ;

316 input ;

317 put _infile_ ;

318 run ;

NOTE: The infile _7ZIP is:

Unnamed Pipe Access Device,

PROCESS="C:\Program Files\7-Zip\7z.exe" l "L:\SDTM\449\11444909\SAS Datasets (2017-02-10).zip",

RECFM=V,LRECL=32767

Stderr output:

'C:\Program' is not recognized as an internal or external command,

operable program or batch file.

NOTE: 0 records were read from the infile _7ZIP.

NOTE: DATA statement used (Total process time):

real time 0.02 seconds

cpu time 0.00 seconds

 

319

320 filename _7zip

321 pipe

322 '"C:\Program Files\7-Zip\7z.exe" l L:\SDTM\449\11444909\SAS_Datasets_(2017-02-10).zip'

323 ;

324

325 data _null_ ;

326 infile _7zip ;

327 input ;

328 put _infile_ ;

329 run ;

NOTE: The infile _7ZIP is:

Unnamed Pipe Access Device,

PROCESS="C:\Program Files\7-Zip\7z.exe" l L:\SDTM\449\11444909\SAS_Datasets_(2017-02-10).zip,

RECFM=V,LRECL=32767

 

7-Zip [64] 16.03 : Copyright (c) 1999-2016 Igor Pavlov : 2016-09-28

Scanning the drive for archives:

1 file, 1259652 bytes (1231 KiB)

Listing archive: L:\SDTM\449\11444909\SAS_Datasets_(2017-02-10).zip

--

Path = L:\SDTM\449\11444909\SAS_Datasets_(2017-02-10).zip

Type = zip

Physical Size = 1259652

Date Time Attr Size Compressed Name

------------------- ----- ------------ ------------ ------------------------

2017-02-10 09:25:15 ....A 147456 11200 ae.sas7bdat

2017-02-10 09:25:15 ....A 81920 5987 cm.sas7bdat

2017-02-10 09:37:32 ....A 65536 5028 co.sas7bdat

2017-02-10 09:25:16 ....A 32768 2102 dc.sas7bdat

2017-02-10 09:25:16 ....A 81920 6575 dm.sas7bdat

2017-02-10 09:25:16 ....A 180224 6893 ds.sas7bdat

2017-02-10 09:25:16 ....A 32768 1626 dt.sas7bdat

2017-02-10 09:32:30 ....A 32768 1719 dv.sas7bdat

2017-02-10 09:25:17 ....A 278528 23356 eg.sas7bdat

2017-02-10 09:25:17 ....A 1556480 99987 ex.sas7bdat

2017-02-10 09:25:29 ....A 5177344 348609 lb.sas7bdat

2017-02-10 09:25:29 ....A 49152 1971 mp.sas7bdat

2017-02-10 09:25:29 ....A 49152 3599 sc.sas7bdat

2017-02-10 09:25:29 ....A 311296 17517 se.sas7bdat

2017-02-10 09:25:29 ....A 131072 4075 sp.sas7bdat

2017-02-10 09:25:31 ....A 5521408 346421 sr.sas7bdat

2017-02-10 09:32:30 ....A 65536 3563 su.sas7bdat

2017-02-10 09:25:31 ....A 32768 1266 suppae.sas7bdat

2017-02-10 09:25:31 ....A 32768 1493 suppdc.sas7bdat

2017-02-10 09:25:31 ....A 344064 8209 suppdm.sas7bdat

2017-02-10 09:25:31 ....A 32768 1476 suppdv.sas7bdat

2017-02-10 09:25:32 ....A 32768 1279 suppeg.sas7bdat

2017-02-10 09:25:32 ....A 1196032 66343 suppex.sas7bdat

2017-02-10 09:25:33 ....A 2850816 135176 suppsr.sas7bdat

2017-02-10 09:25:34 ....A 32768 1731 suppvs.sas7bdat

2017-02-10 09:32:04 ....A 802816 39688 sv.sas7bdat

2017-02-10 09:25:34 ....A 32768 1756 ta.sas7bdat

2017-02-10 09:25:34 ....A 32768 1907 te.sas7bdat

2017-02-10 09:25:34 ....A 32768 3171 ti.sas7bdat

2017-02-10 09:25:34 ....A 32768 2395 ts.sas7bdat

2017-02-10 09:25:34 ....A 32768 1645 tv.sas7bdat

2017-02-10 09:25:35 ....A 1458176 97515 vs.sas7bdat

------------------- ----- ------------ ------------ ------------------------

2017-02-10 09:37:32 20774912 1255278 32 files

NOTE: 49 records were read from the infile _7ZIP.

The minimum record length was 0.

The maximum record length was 77.

NOTE: DATA statement used (Total process time):

real time 0.04 seconds

cpu time 0.00 seconds

 

 

Thank you,

 

Kevin

6 REPLIES 6
Tom
Super User Tom
Super User

What is on the lines before line 309?  Your error message doesn't seem to match the "fix" that you applied.  It seems more likely to me that the FILENAME statement on line 309 never ran and that the first data step used an old definition of the filename.

 

Try running again from a new session. You could also eliminate the FILENAME statement and just specify the command in the INFILE statement. 

INFILE  '"C:\Program Files\7-Zip\7z.exe" l "L:\SDTM\449\11444909\SAS Datasets (2017-02-10).zip"'
  PIPE ;

Personally I like to use %SYSFUNC(QUOTE()) to generate the outer quotes needed.  This will allow you to use macro variables.

%let cmd = C:\Program Files\7-Zip\7z.exe;
%let path = L:\SDTM\449\11444909\SAS Datasets (2017-02-10).zip ;
...
INFILE  %sysfunc(quote("&cmd" l "&path"))  PIPE ;
KevinViel
Pyrite | Level 9

Tom,

 

  That message matches what DOS returns if one submits:

 

C:\Program Files\7-Zip\7z.exe l L:\SDTM\449\11444909\SAS Datasets (2017-02-10).zip

 

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

 

1

2 %let cmd = C:\Program Files\7-Zip\7z.exe;

3 %let path = L:\SDTM\449\11444909\SAS Datasets (2017-02-10).zip ;

4

5 data _null_ ;

6 INFILE %sysfunc(quote("&cmd" l "&path")) PIPE ;

7 input ;

8 put _infile_ ;

9 run ;

NOTE: The infile """C:\Program Files\7-Zip\7z.exe"" l ""L:\SDTM\449\11444909\SAS Datasets

(2017-02-10).zip""" is:

Unnamed Pipe Access Device,

PROCESS="C:\Program Files\7-Zip\7z.exe" l "L:\SDTM\449\11444909\SAS Datasets (2017-02-10).zip",

RECFM=V,LRECL=32767

Stderr output:

'C:\Program' is not recognized as an internal or external command,

operable program or batch file.

NOTE: 0 records were read from the infile """C:\Program Files\7-Zip\7z.exe"" l ""L:\SDTM\449\11444909\SAS

Datasets (2017-02-10).zip""".

NOTE: DATA statement used (Total process time):

real time 0.02 seconds

cpu time 0.01 seconds

 

 

Note the following:

 

45 filename _7zip

46 pipe

47 '"C:\Program Files\7-Zip\7z.exe"'

48 ;

49

50 data _null_ ;

51 infile _7zip ;

52 input ;

53 put _infile_ ;

54 run ;

NOTE: The infile _7ZIP is:

Unnamed Pipe Access Device,

PROCESS="C:\Program Files\7-Zip\7z.exe",

RECFM=V,LRECL=32767

 

7-Zip [64] 16.03 : Copyright (c) 1999-2016 Igor Pavlov : 2016-09-28

Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...]

[<@listfiles...>]

<Commands>

a : Add files to archive

b : Benchmark

<SNIPPED>

 

So the issue is with the subsequent path (7zip runs will just the L option, but I get an error message from it about the archive).  I have asked IT to add the 7-zip path to the environmental variable %path%.  I suspect that calling only 7z.exe will eliminate the issue.

 

Thank you,

 

Kevin

KevinViel
Pyrite | Level 9

A pint to the BOFH* and we get an environmental variable that resolves the issues, within SAS:

 

1

2 filename _7zip

3 pipe

4 '7z.exe l "L:\SDTM\449\11444909\SAS Datasets (2017-02-10).zip"'

5 ;

6

7 data _null_ ;

8 infile _7zip ;

9 input ;

10 put _infile_ ;

11 run ;

NOTE: The infile _7ZIP is:

Unnamed Pipe Access Device,

PROCESS=7z.exe l "L:\SDTM\449\11444909\SAS Datasets (2017-02-10).zip",

RECFM=V,LRECL=32767

 

7-Zip [64] 16.03 : Copyright (c) 1999-2016 Igor Pavlov : 2016-09-28

Scanning the drive for archives:

1 file, 1259652 bytes (1231 KiB)

Listing archive: L:\SDTM\449\11444909\SAS Datasets (2017-02-10).zip

--

Path = L:\SDTM\449\11444909\SAS Datasets (2017-02-10).zip

Type = zip

Physical Size = 1259652

Date Time Attr Size Compressed Name

------------------- ----- ------------ ------------ ------------------------

2017-02-10 09:25:15 ....A 147456 11200 ae.sas7bdat

2017-02-10 09:25:15 ....A 81920 5987 cm.sas7bdat

2017-02-10 09:37:32 ....A 65536 5028 co.sas7bdat

2017-02-10 09:25:16 ....A 32768 2102 dc.sas7bdat

2017-02-10 09:25:16 ....A 81920 6575 dm.sas7bdat

2017-02-10 09:25:16 ....A 180224 6893 ds.sas7bdat

2017-02-10 09:25:16 ....A 32768 1626 dt.sas7bdat

2017-02-10 09:32:30 ....A 32768 1719 dv.sas7bdat

2017-02-10 09:25:17 ....A 278528 23356 eg.sas7bdat

2017-02-10 09:25:17 ....A 1556480 99987 ex.sas7bdat

2017-02-10 09:25:29 ....A 5177344 348609 lb.sas7bdat

2017-02-10 09:25:29 ....A 49152 1971 mp.sas7bdat

2017-02-10 09:25:29 ....A 49152 3599 sc.sas7bdat

2017-02-10 09:25:29 ....A 311296 17517 se.sas7bdat

2017-02-10 09:25:29 ....A 131072 4075 sp.sas7bdat

2017-02-10 09:25:31 ....A 5521408 346421 sr.sas7bdat

2017-02-10 09:32:30 ....A 65536 3563 su.sas7bdat

2017-02-10 09:25:31 ....A 32768 1266 suppae.sas7bdat

2017-02-10 09:25:31 ....A 32768 1493 suppdc.sas7bdat

2017-02-10 09:25:31 ....A 344064 8209 suppdm.sas7bdat

2017-02-10 09:25:31 ....A 32768 1476 suppdv.sas7bdat

2017-02-10 09:25:32 ....A 32768 1279 suppeg.sas7bdat

2017-02-10 09:25:32 ....A 1196032 66343 suppex.sas7bdat

2017-02-10 09:25:33 ....A 2850816 135176 suppsr.sas7bdat

2017-02-10 09:25:34 ....A 32768 1731 suppvs.sas7bdat

2017-02-10 09:32:04 ....A 802816 39688 sv.sas7bdat

2017-02-10 09:25:34 ....A 32768 1756 ta.sas7bdat

2017-02-10 09:25:34 ....A 32768 1907 te.sas7bdat

2017-02-10 09:25:34 ....A 32768 3171 ti.sas7bdat

2017-02-10 09:25:34 ....A 32768 2395 ts.sas7bdat

2017-02-10 09:25:34 ....A 32768 1645 tv.sas7bdat

2017-02-10 09:25:35 ....A 1458176 97515 vs.sas7bdat

------------------- ----- ------------ ------------ ------------------------

2017-02-10 09:37:32 20774912 1255278 32 files

NOTE: 49 records were read from the infile _7ZIP.

The minimum record length was 0.

The maximum record length was 77.

NOTE: DATA statement used (Total process time):

real time 0.08 seconds

cpu time 0.01 seconds

 

 

-Kevin

 

*http://www.theregister.co.uk/data_centre/bofh/

KevinViel
Pyrite | Level 9

With help from Dante DiTommaso, an alternative to requesting IT to create a environmental variable follows:

 

9604  data _null_ ;
9605    infile 'C:\PROGRA~1\7-Zip\7z.exe l "H:\My Documents\SAS - Omeros\Version_Test\DEV\New folder\test_2019-11-25.zip"'
9606           pipe
9607           ;
9608  run ;

NOTE: The infile 'C:\PROGRA~1\7-Zip\7z.exe l "H:\My Documents\SAS - Omeros\Version_Test\DEV\New folder\test_2019-11-25.zip"' is:
      Unnamed Pipe Access Device,
      PROCESS=C:\PROGRA~1\7-Zip\7z.exe l "H:\My Documents\SAS - Omeros\Version_Test\DEV\New folder\test_2019-11-25.zip",
      RECFM=V,LRECL=32767

NOTE: 0 records were read from the infile 'C:\PROGRA~1\7-Zip\7z.exe l "H:\My Documents\SAS - Omeros\Version_Test\DEV\New folder\test_2019-11-25.zip"'.
NOTE: DATA statement used (Total process time):
      real time           0.10 seconds
      cpu time            0.00 seconds

The use of PROGRA~1 solves the conundrum of having a space in the first argument.

 

HTH,

 

Kevin

avz
Obsidian | Level 7 avz
Obsidian | Level 7

@KevinViel , I had a similar challenge trying to execute R code after my SAS code finished running. This approach worked for me:

data _null_;
  infile 'P: & "P:\Some Folder\Another-Folder\And Another Folder\instructions to run 7-Zip or R script.bat" 2>&1' pipe;
  input;
  putlog _infile_;
run;

Credits: https://stackoverflow.com/questions/51957935/executing-bat-file-via-sas

 

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!

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
  • 6 replies
  • 5899 views
  • 2 likes
  • 4 in conversation