The code looks like there may be confusion between the macro language and data step programming. If you want to parse the information out of the automatic filename variable dfnvar the use do not use macro statements at all. You may be able to use this code to read the value of the date part from the file name into a SAS date variable which is much more flexible in the data step and no macro needed: FileDate = input(scan(dfnvar,2,'._'),yymmdd8.); month=month(filedate); QRT = qtr(filedate);
... View more