not the best at macros - having a basic question - here is my code
%macro groupperms(basedir);
filename dirperm pipe "nfs4_getfacl &basedir";
run;
%mend;
data work.temp;
set work.tempdir;
%groupperms(path);
run;
the table work.tempdir has a character variable called path
path has a value of: /u02/projects
just not able to get the right value passed to the filename statement
What exactly are you trying to accomplish? FILENAME has a different call in a datastep as you are calling the filename FUNCTION not the statement. Also data set variables aren't going to be accessible to the macro processor unless you use CALL EXECUTE.
Are there more than one record in work.tempdir? If not and you want to create a fileref from work.tempdir try:
proc sql;
select path into :basedir
from work.tempdir;
quit;
filename dirperm pipe "nfs4_getfacl &basedir";
Your macro is not generating code that belongs inside of a data step.
You have asked the macro to generate a FILENAME statement using the string path as the value of the BASEDIR parameter. So the result will be
filename dirperm pipe "nfs4_getfacl path";
But you are not even trying to access this filename, even if it was generated properly.
So your data step is just making a copy of the input data.
You probably want to using the FILEVAR option on the INFILE command instead. Perhaps something like this:
data work.temp;
set work.tempdir;
filevar=catx(' ','nfs4_getfacl',path);
do while (not eof);
infile dirperm pipe filevar=filevar end=eof truncover;
input facl $80. ;
output;
end;
run;
This will add the character variable FACL with the output of the program and generate one observation for every line that the program outputs for that particular path. In reality you might want to read the output into more than one variable.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.