BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Suzy_Cat
Pyrite | Level 9

Hi there,

 

we have a project runs on a weekly basis and the final result needs be saved as a dataset in the library GOT.

 

When a different user is running the project, the error message will come up as below:

ERROR: User does not have appropriate authorization level for file GOT.WEEKLY_data.DATA.

 

data GOT.WEEKLY_Data;

set work.WEEKLY_Data;

run;

 

Ideally, no matter who is running the project, the output can be saved to the same dataset in the library (GOT.WEEKLY_Data).

 

Can any one help me to sort the user issue?

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

If you want to change the permissions of a dataset file, keep in mind that such files have all-lowercase filenames and end with .sas7bdat.

 

But you should not fix your issue after the fact. Issue this

x "umask 002";

before you create your dataset, and all will be OK.

See this short example:

data sasuser.test1;
set sashelp.class;
run;

x 'umask 002';

data sasuser.test2;
set sashelp.class;
run;

%let path=%sysfunc(pathname(sasuser));

filename oscmd pipe "ls -l &path./test*";

data _null_;
infile oscmd;
input;
put _infile_;
run;

x "chmod 664 &path./test1.sas7bdat";

data _null_;
infile oscmd;
input;
put _infile_;
run;

Log (redacted for user and group names, and the home path):

37         data sasuser.test1;
38         set sashelp.class;
39         run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set SASUSER.TEST1 has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      

40         
41         x 'umask 002'
41       !              ;
42         
43         data sasuser.test2;
44         set sashelp.class;
45         run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
2                                                          Das SAS System                            08:21 Tuesday, November 5, 2019

NOTE: The data set SASUSER.TEST2 has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
      

46         
47         %let path=%sysfunc(pathname(sasuser));
48         
49         filename oscmd pipe "ls -l &path./test*";
50         
51         data _null_;
52         infile oscmd;
53         input;
54         put _infile_;
55         run;

NOTE: The infile OSCMD is:
      Pipe-Kommando="ls -l XXXX/sasuser.v94/test*"

-rw-r--r--    1 XXXXX    group     131072 Nov 05 08:21 XXXX/sasuser.v94/test1.sas7bdat
-rw-rw-r--    1 XXXXX    group     131072 Nov 05 08:21 XXXX/sasuser.v94/test2.sas7bdat
NOTE: 2 records were read from the infile OSCMD.
      The minimum record length was 104.
      The maximum record length was 104.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
      

56         
57         x "chmod 664 &path./test1.sas7bdat"
57       !                                    ;
58         
59         data _null_;
60         infile oscmd;
61         input;
62         put _infile_;
63         run;

NOTE: The infile OSCMD is:
      Pipe-Kommando="ls -l XXXX/sasuser.v94/test*"

-rw-rw-r--    1 XXXXX    group     131072 Nov 05 08:21 XXXX/sasuser.v94/test1.sas7bdat
-rw-rw-r--    1 XXXXX    group     131072 Nov 05 08:21 XXXX/sasuser.v94/test2.sas7bdat

You can see that the second test dataset created after the umask command now had group write permission set; and you can see how to easily retrieve a path with the pathname function, and how to apply the chmod command to a dataset file. Finally, you can also see the best way to run external commands by using a filename pipe.

View solution in original post

12 REPLIES 12
Suzy_Cat
Pyrite | Level 9

Hi there,

 

further to my question, I have searched a solution and tested but failed :

 

http://support.sas.com/kb/25/198.html

 

%macro chmod(libname,dataset,permis=777);

  proc sql;
     /* get the absolute path of the libname */
     select path into: extpath from dictionary.members
       where libname="%UPCASE(&LIBNAME)";

     /* find out if there are any datasets in the library */
     select count(path) into: cnt from dictionary.members
       where libname="%UPCASE(&LIBNAME)";

     /* if there are datasets...then issue the below command to change the
        permissions of the dataset called in this macro  to 777 */
     %if &cnt > 0 %then %do;
        filename chmod pipe "chmod &PERMIS %trim(&extpath)/&dataset..sas7bdat";
        data _null_;
          file chmod;
        run;
     %end;
%mend;

 

/* assign a libref to test the macro */
libname GOT '/*******/******/****';

/* test the macro on the 'WEEKLY_Data' dataset in the 'GOT' library */
%chmod(GOT,WEEKLY_Data);

 

 

Tom
Super User Tom
Super User

(1) Is SAS actually running on Unix?

(2) You need to change the permissions on the directory where the .sas7bdat file lives. When you run:

data x.y;
  set x.y;
run;

SAS will make a NEW file in the directory where X points.  Then if the step completes it will delete y.sas7bdat and rename the file it made to y.sas7bdat.  So you need write access to the directory.  Write access to the file is probably not important.

Suzy_Cat
Pyrite | Level 9

Hi Tom,

 

1) SAS EG is running from server.

2) I don't really understand the terminology "X points", therefore I don't know how to getting there as to your suggestion?

I can create new datasets in the library  GOT, does that mean I do have the write access to the directory?

 

Thanks


Sue

 

 

Suzy_Cat
Pyrite | Level 9

after I run the macro,  log provided below info:

 

Pipe command="chmod 777 /sas_user_*****/***_WEEKLY_data"

Message(s) received from the pipe command:
chmod: cannot access `/sas_user_*****/***_WEEKLY_data': No such file or directory

Reeza
Super User
You'll need to find the unix path to the files you need - may need to ask IT or when you assign the libname, right click the folder and get the path to ensure it's correct.

If the whole folder is locked away from you that may part of the issue in the first place.
Kurt_Bremser
Super User

If you want to change the permissions of a dataset file, keep in mind that such files have all-lowercase filenames and end with .sas7bdat.

 

But you should not fix your issue after the fact. Issue this

x "umask 002";

before you create your dataset, and all will be OK.

See this short example:

data sasuser.test1;
set sashelp.class;
run;

x 'umask 002';

data sasuser.test2;
set sashelp.class;
run;

%let path=%sysfunc(pathname(sasuser));

filename oscmd pipe "ls -l &path./test*";

data _null_;
infile oscmd;
input;
put _infile_;
run;

x "chmod 664 &path./test1.sas7bdat";

data _null_;
infile oscmd;
input;
put _infile_;
run;

Log (redacted for user and group names, and the home path):

37         data sasuser.test1;
38         set sashelp.class;
39         run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set SASUSER.TEST1 has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      

40         
41         x 'umask 002'
41       !              ;
42         
43         data sasuser.test2;
44         set sashelp.class;
45         run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
2                                                          Das SAS System                            08:21 Tuesday, November 5, 2019

NOTE: The data set SASUSER.TEST2 has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
      

46         
47         %let path=%sysfunc(pathname(sasuser));
48         
49         filename oscmd pipe "ls -l &path./test*";
50         
51         data _null_;
52         infile oscmd;
53         input;
54         put _infile_;
55         run;

NOTE: The infile OSCMD is:
      Pipe-Kommando="ls -l XXXX/sasuser.v94/test*"

-rw-r--r--    1 XXXXX    group     131072 Nov 05 08:21 XXXX/sasuser.v94/test1.sas7bdat
-rw-rw-r--    1 XXXXX    group     131072 Nov 05 08:21 XXXX/sasuser.v94/test2.sas7bdat
NOTE: 2 records were read from the infile OSCMD.
      The minimum record length was 104.
      The maximum record length was 104.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
      

56         
57         x "chmod 664 &path./test1.sas7bdat"
57       !                                    ;
58         
59         data _null_;
60         infile oscmd;
61         input;
62         put _infile_;
63         run;

NOTE: The infile OSCMD is:
      Pipe-Kommando="ls -l XXXX/sasuser.v94/test*"

-rw-rw-r--    1 XXXXX    group     131072 Nov 05 08:21 XXXX/sasuser.v94/test1.sas7bdat
-rw-rw-r--    1 XXXXX    group     131072 Nov 05 08:21 XXXX/sasuser.v94/test2.sas7bdat

You can see that the second test dataset created after the umask command now had group write permission set; and you can see how to easily retrieve a path with the pathname function, and how to apply the chmod command to a dataset file. Finally, you can also see the best way to run external commands by using a filename pipe.

Suzy_Cat
Pyrite | Level 9

it worked.

 

instead of using the existing dataset, I have created a new dataset and used PUTTY and "chmod 770" to change the new dataset with "-rw-rw-r-- " to the group, I believe the problem is resolved and other members in the team can run the project and override the new dataset from then.

 

 

Thanks for everyone who has helped.:)

TomKari
Onyx | Level 15

Two questions:

 

1. Are you saying that there is one user for whom it works, but if any other user tries to run it the program fails with that error message? If not, please describe the scenario in more detail.

 

2. Is it absolutely certain that only one person at a time is trying to run the program? Are you sure that no one else is trying to change GOT.WEEKLY_DATA in any way?

 

Tom

 

Suzy_Cat
Pyrite | Level 9

Hi TomKari,

 

Yes, only 1 person from the team will be running it on a weekly basis. Currently problem is if the original file is created by one of member, other member from the team can only access the file but not update the file.

 

I believe it is to do with read/write access to the file, but don't have enough knowledge to resolve it myself. Tom may have provided a solution but I don't quite get it yet.

 

Cheers

 

Sue

Reeza
Super User
By default SAS is creating the file with permissions only for the creator. Any time I've encountered this, I've had to manually change it using CHMOD which you need x command to do.

Verify you have x command enabled using:

proc options option =xcmd;
run;

There may be a way to change this via administrator settings but I'm not aware of it and it's definitely annoying as hell when working in a team environment.
Suzy_Cat
Pyrite | Level 9

Hi Reeza,

 

Totally agreed what you said.

 

I have run below code and confirmed x command enabled- what next?

proc options option =xcmd;
run;

 

 

The X Command is valid in this SAS session.

Patrick
Opal | Level 21

@Suzy_Cat 

It's very often desirable to set the default in a way so that all members of a security group get full access to files independent on who has created them. In Unix/Linux that can be done via a UMASK.

It requires a change to the configuration. Best talk to the SAS admin for your site. http://support.sas.com/kb/38/040.html 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 12 replies
  • 16572 views
  • 8 likes
  • 6 in conversation