Hi all I am trying to import the latest created file by the data at the end of it's name form a location. I have the below code that I am sure used to work but I am now getting an error (also provided below), can anyone assist and tell me what's wrong with the Macro as I can't work it out. %LET location = \\Drive and file location entered here\file name here; Code being run %MACRO get_filenames(location); filename _dir "%bquote(&location.)"; data filenames(keep=memname SeqNo Extention ); Excel_Dir=dopen( "_dir" ); if Excel_Dir > 0 then do; count=dnum(Excel_Dir); do i=1 to count; memname=dread(Excel_Dir,i); SeqNo =i; Extention = substr(memname,index(memname,".")+1,length(memname)); if Extention = "txt" then Extention = "txt"; output filenames; end; end; rc=dclose(Excel_Dir); call symput("MaxID",SeqNo); call symput("Extention",Extention); run; %DO j = 1 %TO &MaxID.; data _null_; set work.filenames; where SeqNo = &j.; call symput("inputfile",memname); call symput("Position",(length(memname)-(length(Extention)+1))); run; %END; %MEND get_filenames; /* Create a stamp (set as todays date) */ DATA _null_; FORMAT Stamp $10.; Stamp = put(today(),date9.); CALL symput('Stamp',Stamp); RUN; %PUT &Stamp; %get_filenames(%bquote("&location.")); /* Select the name of the latest file by the max SeqNo */ PROC SQL NOPRINT; SELECT compress(memname) INTO: fileName FROM filenames WHERE SeqNo IN (SELECT max(SeqNo) FROM filenames) ;QUIT; %PUT &fileName. ; Error I am receiving ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &MaxID. ERROR: The %TO value of the %DO J loop is invalid. ERROR: The macro GET_FILENAMES will stop executing. Any idea what could be wrong with the above? Thanks
... View more