Hi,
I am using a macro to open multiple txt files from a directory but want to store them under a subsetname of the files. Once i assign the file name it can't store it because of the txt extension, how can i make it to store my the files? Could somebody please help me figure out what is wrong here?
This is the code;
macro basic1;
%let filrf=mydir;
%let rc=%sysfunc(filename(filrf,"F:\RESEARCH MELISSA\Short USA DATA\")); /* assign dir name */
%let did=%sysfunc(dopen(&filrf)); /* open directory */
%let lstname=; /* clear filename macro var */
%let memcount=%sysfunc(dnum(&did)); /* get # files in directory */
%if &memcount > 0 %then /* check for blank directory */
%do i=1 %to &memcount; /* start loop for files */
%let lstname=%sysfunc(dread(&did,&i)); /* get file name to process */
%let lstname2=%sysfunc(substr("&lstname",24,7));
filename dr "F:\RESEARCH MELISSA\Short USA DATA\&lstname"; /* assign file name */
proc import out=&LSTNAME2
datafile=dr;
DBMS=TAB Replace;
getnames=yes;
datarow=2;
run;
%end;
%let rc=%sysfunc(dclose(&did));
%mend basic1;
Message was edited by: mporras