Hi:
This is not really an ODS-related question. Generally speaking, with SAS Macro programs, I always recommend starting with a working SAS program. When I write PROC IMPORT code, I generally write it like this:
[pre]
** step 1: Have a working SAS program;
proc import out=myfile1
datafile="C:\DataDir\myfiles\file1.csv"
dbms=csv
replace;
delimiter=';';
getnames=yes;
run;
or
filename mycsv "C:\DataDir\myfiles\file1.csv";
proc import out=myfile1
datafile=mycsv
dbms=csv
replace;
delimiter=';';
getnames=yes;
run;
[/pre]
So, then, if I were going to turn this program into a program that used macro variables, I would alter it to be something like this:
[pre]
** step2: Modify the working SAS program to use macro variables;
** that are set with %LET statements;
%let outsas=myfile1;
%let incsv = %str(C:\DataDir\myfiles\file1.csv);
proc import out=&outsas
datafile="&incsv"
dbms=csv
replace;
delimiter=';';
getnames=yes;
run;
or
filename mycsv "&incsv";
proc import out=&outsas
datafile=mycsv
dbms=csv
replace;
delimiter=';';
getnames=yes;
run;
[/pre]
Note the need for quotes around the physical data file name -- since it is a fully qualified operating system path and location. However, I do not need quotes around the output SAS data set name because SAS file names do not need to be quoted in code. You also do NOT need quotes around a FILEREF -- however, you do need quotes in a FILENAME statement. Once you have tested step 1 and then tested step 2, you now know where quotes are needed when you convert your program from step 2 to become a macro program (this would be step 3).
For help with PROC IMPORT or debugging macro code or data step problems, your best bet is to contact Tech Support. They can look inside your "MAESTRO" data set that is providing the file names for the CALL EXECUTE invocation of %IMPORT and advise you where you might be running into problems with your code.
To learn how to contact Tech Support, refer to:
http://support.sas.com/techsup/contact/index.html
cynthia
PS -- as a method of streamlining your code, you might consider the following alternative for the second half of the code (once your macro is working). It would allow you to eliminate your PROC CONTENTS step, the PROC SORT step and the PROC SQL step all in one alternative section of code, by using the automatic file DICTIONARY.TABLES (and produce the same results as the above 3 steps):
[pre]
proc sql noprint;
select distinct(memname) into :altfile separated by " "
from dictionary.tables
where substr(memname,1,1) = "A" and
libname = 'WORK'
order by memname;
quit;
%put &altfile;
Data all_file2;
set &altfile;
run;
[/pre]