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

I am trying to use %sysexec chmod to set permission for files

issue is files are named with the timestamp which is hard to add in the code itself

any suggested workarounds?

 

files names like the below:

CORE_BANK_OUT1_20200423T145023.txt

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

@MAGED_AKL wrote:

 

the need is to give permission to all files starting with the fixed prefix "CORE_BANK_OUT"


Well, that's easy, as chmod accepts a list of files, and the shell expands wildcards:

filename oscmd pipe "chmod 600 /sas/SASConfig/Lev1/Applications/SASComplianceSolutions/FCFBU1/reports/risk_rating_report/Finished/SAS_CORE_BANK_OUT* 2>&1";

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

(replace the 600 with whatever permissions you need)

As chmod remains "silent" if everything is OK, a look at the SAS log will tell you if something untoward happened.

View solution in original post

6 REPLIES 6
Patrick
Opal | Level 21

Try first to get that working out of a command prompt without using SAS at all. 

You could Google with keywords like: linux chmod multiple files

 

Once you've got the OS command working and you need to call it via SAS then I'd go for a Filename Pipe approach over using %sysexec()

Kurt_Bremser
Super User

What do you know about the files? Do they all start with CORE_BANK_OUT1_? Or do you need to apply your chmod for all files with a specific timestamp?

The common criteria will define which logic to use.

The format of your timestamp is "basic ISO", for which SAS provides the format B8601DT15.

MAGED_AKL
Calcite | Level 5

files are extracted using a sas code on a AIX environment

 

data _null_;
call symputx('timestamp',put(datetime(),B8601DT.));
run;

PROC EXPORT DATA=CORE_BANK_OUTT&i
OUTFILE="/sas/SASConfig/Lev1/Applications/SASComplianceSolutions/FCFBU1/reports/risk_rating_report/Finished/SAS_CORE_BANK_OUT&i._&timestamp..txt"
DBMS=dlm REPLACE;
DELIMITER='|';
RUN;

 

where &i represents the sequence of the file

the need is to give permission to all files starting with the fixed prefix "CORE_BANK_OUT"

Kurt_Bremser
Super User

@MAGED_AKL wrote:

 

the need is to give permission to all files starting with the fixed prefix "CORE_BANK_OUT"


Well, that's easy, as chmod accepts a list of files, and the shell expands wildcards:

filename oscmd pipe "chmod 600 /sas/SASConfig/Lev1/Applications/SASComplianceSolutions/FCFBU1/reports/risk_rating_report/Finished/SAS_CORE_BANK_OUT* 2>&1";

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

(replace the 600 with whatever permissions you need)

As chmod remains "silent" if everything is OK, a look at the SAS log will tell you if something untoward happened.

MAGED_AKL
Calcite | Level 5

Worked great

Thanks 

Patrick
Opal | Level 21

@MAGED_AKL wrote:

files are extracted using a sas code on a AIX environment

 

data _null_;
call symputx('timestamp',put(datetime(),B8601DT.));
run;

PROC EXPORT DATA=CORE_BANK_OUTT&i
OUTFILE="/sas/SASConfig/Lev1/Applications/SASComplianceSolutions/FCFBU1/reports/risk_rating_report/Finished/SAS_CORE_BANK_OUT&i._&timestamp..txt"
DBMS=dlm REPLACE;
DELIMITER='|';
RUN;

 

where &i represents the sequence of the file

the need is to give permission to all files starting with the fixed prefix "CORE_BANK_OUT"


If above is the process which creates the files then you could eventually set a UMASK before so the files get created with the desired permissions from start.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 2125 views
  • 1 like
  • 3 in conversation