I'll be more explicit. Here's the macro: %macro GetData(mpfile); **The macro variable InputData will be created in the GetData macro, ; %global InputData; filename TempFile temp lrecl=4000; data _null_; infile "&mpfile" lrecl=4000; file TempFile; input; if lengthc(_infile_) > 0 then do; if substr(_infile_,1,1) in ("$","!","*") then put _infile_; end; run; data _null_; slashloc = length("&mpfile") - index(reverse(trim("&mpfile")),'\') + 1; **We subtract 4 at the end to remove the file extension; InputData = substr("&mpfile",slashloc+1,length("&mpfile")-slashloc-4); call symputx('InputData',InputData); run; **proc import is cancelled if there are no observations in TempFile. No output dataset is produced. ; **Will need to test later if that output dataset exists or not before doing any processing on it; proc import datafile = TempFile out = &InputData dbms = csv replace; getnames=yes; guessingrows=5000; run; %mend; ************* In the middle data step, a macro variable is created, &InputData, which is declared as Global at the top of the macro. It isn't obvious in the program that calls the macro that this global variable is created here. An alternative would be to declare it as global in the calling program, but then someone might ask, "why is he declaring a variable that he isn't using? Where is he ising it?" Both program and macro work correctly as they are, my question is, is there a *clearer* way of doing this? Clearer to any future programmers?
... View more