- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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()
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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._×tamp..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"
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Worked great
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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._×tamp..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.