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

I need to create several external files and establish their permissions as u=rwx, g=rwx, and o=r-x.  I can accomplish this easily if an output file isn't created using "FILEVAR".  Can I not do this using "FILEVAR"?  Please see the attached code.  What is the proper way?

 

Jackie O.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Note that since you are turning on the group write bit on the files you might will also want to make sure to turn it on for the folder.

You might also want to set the group sticky bit on the folder when it is created. That way all files created in the folder will be in the same group.

 

mkdir -p myfolder
chmod g+s,g+w myfolder
cd myfolder
umask 002 
sas myprogram

View solution in original post

8 REPLIES 8
JackieO
Obsidian | Level 7
Hello,
I hadn't seen the first reference, but had the second. Thank you for your help. Doing a "find" on both yields nothing concerning "PERMISSION".
Perhaps I was unclear concerning my problem. I just recently began using "FILEVAR". I can create the external files, but only with my profile settings
for file permissions. Those external files need different permissions for group. Too many to chmod. Hoped to modify the permissions while
the files are being generated. Someone else in my group will be using these files when running an editing application.
Jackie O
ChrisHemedinger
Community Manager

Depending on how the SAS session is started (shell command? using a Workspace server in SAS EG or SAS Studio?), you may be able to influence the default permissions by setting the umask -- see this note.

 

Oh, but I see your question is about FILEVAR -- I think the answer is No, it doesn't work that way with PERMISSION.

 

Here's an explanation that I cribbed from another support question:

When you use the FILEVAR= option, the file-specification is just a placeholder, not an actual filename or a fileref that has been previously assigned to a file.  When you do not use the FILEVAR= option you are using the actual filename or a fileref hence allowing to set the permissions using the permissions option (PERMISSION='permission-value').  The PERMISSION value isn't assigned "dynamically" as the active file changes out during multiple passes of the DATA step.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Tom
Super User Tom
Super User

@ChrisHemedinger 

The documentation doesn't mention any such limitations on the new PERMISSION option.

https://documentation.sas.com/?docsetId=hostunx&docsetTarget=p0upngkius4n84n17wt1u5znj2de.htm&docset...

 

ChrisHemedinger
Community Manager

I understand @Tom -- but just relaying information I saw in another internal support case.  Maybe it *should* work -- and you might be correct to expect it to -- but I don't want you to waste time trying to make it work if it won't.  If you think it's important, I suggest working with SAS Tech Support to pursue possibility of a change. There are workarounds perhaps not as elegant as FILEVAR with PERMISSIONS -- like macro or CALL EXECUTE to define all of the files with permissions ahead of the step.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
JackieO
Obsidian | Level 7

Chris and Tom,

 

Thank you for the quick responses.  My SAS application is executed within a korn-shell script.  Looks like I can control permissions using umask as you have suggested.  If this doesn't work for me, I will explore macros, but have minimal experience working with them.  Still would love to know why a single file created works perfectly with the PERMISSION option for the FILE statement, while multiple files using FILEVAR does not.  At least not for me. 🙂

 

Again...thank you!

Jackie O.

Tom
Super User Tom
Super User

Note that since you are turning on the group write bit on the files you might will also want to make sure to turn it on for the folder.

You might also want to set the group sticky bit on the folder when it is created. That way all files created in the folder will be in the same group.

 

mkdir -p myfolder
chmod g+s,g+w myfolder
cd myfolder
umask 002 
sas myprogram
JackieO
Obsidian | Level 7

Thank you all for your help.  Consider this case closed. 🙂

Jackie O

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 8 replies
  • 2517 views
  • 1 like
  • 4 in conversation