BookmarkSubscribeRSS Feed
RodNeal
SAS Employee

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

2 REPLIES 2
ballardw
Super User

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";

Tom
Super User Tom
Super User

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1187 views
  • 0 likes
  • 3 in conversation