Help using Base SAS procedures

PROC IMPORT Problem

Accepted Solution Solved
Reply
Super Contributor
Posts: 358
Accepted Solution

PROC IMPORT Problem

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.


Accepted Solutions
Solution
‎02-27-2012 11:34 AM
PROC Star
Posts: 7,364

Re: PROC IMPORT Problem

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


All Replies
PROC Star
Posts: 7,364

PROC IMPORT Problem

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 ;

Super Contributor
Posts: 358

Re: PROC IMPORT Problem

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

Solution
‎02-27-2012 11:34 AM
PROC Star
Posts: 7,364

Re: PROC IMPORT Problem

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 ;

Super Contributor
Posts: 358

PROC IMPORT Problem

Art:

Much better.

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

Thanks again.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 515 views
  • 0 likes
  • 2 in conversation