Hello, I am using the following code to get the owner and group and it works well only if there is no space into the macro variable provided.
ex:
%macro find_owner(f);
* this will find the file owner;
filename fog pipe "ls -la &f. | awk '{print $3, $4}'";
data _null_ ;
infile fog truncover delimiter="|";
input xvalue :$256.;
call symput('owner',strip(substr(xvalue,1,index(xvalue," "))));
call symput('group',strip(substr(xvalue,index(xvalue," "),200)));
run;
%put &=owner &=group;
%mend find_owner;
The first call is working properly because there is no blank into the macro variable &f.
%find_owner(/finsys/lego816/saspgm/sasmacro/program1.sas);
But for the second one, there is a blank into the macro variable &f. between lego and 816. Is there a way to overcome this situation.
%find_owner(/finsys/lego 816/saspgm/sasmacro/program1.sas);
Also, when there is a space into the path or file name, I am not sure the macro macro variable will pick the complete path and program name.
I think you are overcomplicating things:
data _null_;
infile "ls -l '&f.'" pipe;
input perms :$10. links owner :$8. group :$8.;
call symputx("owner",owner);
call symputx("group",group);
run;
%put &=owner &=group;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.