0
votes

I have been trying to change the permissions of all the output datasets created by a SAS code. I know that I can use the chmod command post a dataset's creation to change the permissions. But, what if I have multiple outputs from a code and i want to change their permissions, then how can I dynamically apply chmod on every dataset created in the code without having to manually supply dataset names? Ex. If my SAS code does this :

`Data Lib1.test1
     Lib2.test2
     Lib3.test3;
Set Work.Test;
If (certain conditions) then output Lib1.test1;
If (certain conditions) then output Lib2.test2;
If (certain conditions) then output Lib3.test3;
run;`

How can I apply chmod to all these datasets after they have been created without having to manually supply the dataset names. I know &syslast can give me the last touched dataset, but what about the other two? P.S. I can't update the Data step code block here, I can only add code post the end of the Data step mentioned above.

I tried using the Umask command in the very beginning of the session, but it does not let me set the execute permissions. X umask 000 It only sets rw,rw,rw settings for datasets does not give u=rwx,g=rwx,o=rwx permissions.

1
Why would you want to set execute flags on a dataset? - david25272
Right, makes sense! But, is there a way to achieve this query using chmod and not Umask? - Rhea

1 Answers

3
votes

Two options:

  1. Try setting the setgid bit on the folders where your datasets are created. They should then automatically inherit their group permissions from the folder. E.g. chmod g+s /mydir
  2. Use a wildcard command to set the permissions for all sas datasets in a folder, e.g. chmod g=rw /mydir/*.sas7bdat