Using SAS Macro to pipe a list of filenames from a Windows directory
Posted
by Bazil
on Stack Overflow
See other posts from Stack Overflow
or by Bazil
Published on 2009-09-11T07:49:12Z
Indexed on
2010/03/15
18:39 UTC
Read the original article
Hit count: 677
I am trying to amend the macro below to accept a macro parameter as the 'location' argument for a dir command. However I cannot get it to resolve correctly due to the nested quotes issue. Using %str(%') does not work, neither do quoting functions for some reason.
The macro will work fine when the filepath has no spaces (eg C:\temp\withnospace) as the middle quotes aren't needed. However I need this macro to work for filepaths with spaces (eg 'C:\temp\with space\').
Please help!
%macro get_filenames(location)
filename pipedir pipe "dir &location. /b " lrecl=32767;
data filenames;
infile pipedir truncover;
input line $char1000.;
run;
%mend;
%get_filenames(C:\temp\) /* works */
%get_filenames('C:\temp\with space') /* doesnt work */
© Stack Overflow or respective owner