BookmarkSubscribeRSS Feed
alepage
Barite | Level 11

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.

4 REPLIES 4
alepage
Barite | Level 11
Forget about the question, I have found the solution which is to put the information provided in the call is single quote.
Reeza
Super User
You can post the answer, corrected, and mark that as the solution. I'm certain someone else will ask this or google it at some point.
alepage
Barite | Level 11
For example:

%find_owner('/finsys/lego 816/saspgm/sasmacro/program1.sas');
Kurt_Bremser
Super User

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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1809 views
  • 0 likes
  • 3 in conversation