Background is that I need to use filename command to execute grep and use the result as input.
Here is my input data set named test
firstname lastname filename
<blank> <blank> cus_01.txt
<blank> <blank> cus_02.txt
Filename values are actual files which I need to grep because I need certain string inside those files to fill up the firstname and lastname
Here is the code:
data work.test;
set work.test;
call symputx('file', filename);
filename fname pipe "grep ""Firstname"" <path>/&file.";
filename lname pipe "grep ""Lastname"" <path>/&file.";
infile fname;
input firstname;
infile lname;
input lastname;
run;
However, macro variables created inside a data step can't be used until after the data step procedure is completed. So, that means, &file. can't be resolved and can't be used in filename.
Is there a way to for resolve the macro variable?
Thanks!