DATA Step, Macro, Functions and more

Windows and pipe with spaces in the path/file name

Reply
Frequent Contributor
Posts: 83

Windows and pipe with spaces in the path/file name

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

Super User
Super User
Posts: 7,039

Re: Windows and pipe with spaces in the path/file name

Posted in reply to KevinViel

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 ;
Frequent Contributor
Posts: 83

Re: Windows and pipe with spaces in the path/file name

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

Frequent Contributor
Posts: 83

Re: Windows and pipe with spaces in the path/file name

Posted in reply to KevinViel

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/

Ask a Question
Discussion stats
  • 3 replies
  • 336 views
  • 0 likes
  • 2 in conversation