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

Hi All:

When I run the following code:

  filename DIRLIST pipe "dir  &dircmd";                                                                                                

  data dirlist ;                                                                                                                       

  length buffer $256 ;                                                                                                                 

  infile dirlist length=reclen ;                                                                                                       

  input buffer $varying256. reclen ;                                                                                                   

  run ;

Where &dircmd resolves to "p:\sas\data\input lib\*.*"

the program fails on:

  Stderr output:

  The system cannot find the file specified. 

  NOTE: 0 records were read from the infile DIRLIST.

But - if I change the space in the name to an underscore - ( input_lib ) - then the program works OK. 

Is it possible to get it to work with the space in the file name?

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

I got it to work NOT.  I didn't check the output file.  However, the following DID work:

%let dircmd=c:\art\input lib\*.*;

filename DIRLIST pipe "dir %bquote("&dircmd.")";

  data dirlist ;

   length buffer $256 ;

   infile dirlist length=reclen ;

   input buffer $varying256. reclen ;

   run ;

View solution in original post

4 REPLIES 4
art297
Opal | Level 21

The following works for me:

%let dircmd=c:\art\input lib\*.*;

filename DIRLIST pipe 'dir  "&dircmd"';                                                                                               

  data dirlist ;                                                                                                                      

   length buffer $256 ;                                                                                                                

   infile dirlist length=reclen ;                                                                                                      

   input buffer $varying256. reclen ;                                                                                                  

   run ;

OS2Rules
Obsidian | Level 7

Art:

How on earth did you get that to work?

you have your macro variable within single quotes....

When I try it I get:

NOTE: The infile DIRLIST is:

      Unnamed Pipe Access Device,

      PROCESS=dir  "&dircmd",RECFM=V,LRECL=256

Stderr output:

File Not Found

art297
Opal | Level 21

I got it to work NOT.  I didn't check the output file.  However, the following DID work:

%let dircmd=c:\art\input lib\*.*;

filename DIRLIST pipe "dir %bquote("&dircmd.")";

  data dirlist ;

   length buffer $256 ;

   infile dirlist length=reclen ;

   input buffer $varying256. reclen ;

   run ;

OS2Rules
Obsidian | Level 7

Art:

Much better.

I'm not so up on these new fangled macro functions, but that works.

Thanks again.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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