file permission

Reply
Contributor
Posts: 30

file permission


Hi experts,

I execute a data step using enterprise guide.

data newtable;

     set existtab;

          code statement1..

          code statement2...

run;

after this data step is it possible to set desired read /write permission for this new table.  (by using sas code only)?

(Like how we change read/write permission of a file with a Unix command on unix prompt  -> chmod 666 filename; similarly can we do that using SAS code...???)

Grand Advisor
Posts: 10,251

Re: file permission

Proc Datasets with the modify statement may do what you are looking for depending upon the permission you want.

PROC DATASETS LIBRARY=libref MEMTYPE=member-type;
MODIFY member-name (password-level = password-modification);

run;

quit;

Password levels are READ=, WRITE=, ALTER= or PW=. The password can be different for each level.

Contributor
Posts: 30

Re: file permission

Thanks Ballardw for your reply...

I looked at PROC DATASETS and I am a bit confused..  as  READ=, WRITE=, ALTER= or PW=.  are for giving passwords...

I will try to make my question more clear..

Suppose I have a dataset XYZ.sas7bdat

On unix system , when I do  ->  ls -ltr XYZ.sas7bdat

I get,

-rw-------       ownername    XYZ.sas7bdat

Now , as per your suggestions , after using PROC datasets, how can I get following ......

-rw-rw-rw-     ownername    XYZ.sas7bdat

Thanks !

Super Contributor
Posts: 644

Re: file permission

You need to issue the unix chmod command to change permissions, using the SAS X command or one of it's cousins.

From memory it would be something like

X chmod 666 filename ;

which might have to be remote submitted

Richard

Super Contributor
Posts: 644

Re: file permission

But if you are not the owner of the file and the permissions are -rw-------  chmod will fail.  You should talk to you IT guys about changing your user profile to create files with the required permissions.

Richard

New Contributor
Posts: 3

Re: file permission

If you do not have permissions andnot the owner unix will not let you write to the file.

 

SAS code will error.

 

You may want to use,

filename chmod pipe "chmod 777 /home/source/datasetname.sas7bdat";
data _null_; file chmod; run;

Esteemed Advisor
Posts: 5,202

Re: file permission

Changing permissions after file creation is awkward. Consider setting default file permissions instead (umask).
Data never sleeps
New Contributor
Posts: 3

Re: file permission

Yes that is also a good idea.
In live environments where we have end users with access to files it may just be helpful to give permissions once the entire job processing is complete.
Wouldn't want someone opening a file in SAS while process is running. May cause job to abend.
So the method you would want to use may be subjective to the type or environment setup and your process.
Ask a Question
Discussion stats
  • 7 replies
  • 5159 views
  • 0 likes
  • 5 in conversation