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

All,

I have file on s3 bucket(static file name  ex:test.txt ) and that file over writes everyday.

So I need to read that file based on modified date.

ex:If test.txt  modified date is today then run Proc s3 otherwise file is not modified today.

 

 

proc s3 config="/u/marti/.tks3.conf";
   create "/myBucket";
   put "/u/marti/project/test.txt" "/myBucket/test.txt";
run;

Thanks,

SS

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

Try:

Step 1: Momentarily redirect the log with proc PRINTTO

Step 2: Run proc S3 with INFO statement (or LIST? which one gives you the date?)

Step 3: Stop the redirection: run proc PRINTTO again

Step 4: Run a data steps that analyses the log file.

           This data steps triggers a new proc S3 run if the date is as expected.

View solution in original post

8 REPLIES 8
ChrisNZ
Tourmaline | Level 20

What do you get when you run the INFO statement? 

smantha
Lapis Lazuli | Level 10

Doesn't list give you the information you need

sathya66
Barite | Level 11

proc s3 config="/u/marti/.tks3.conf"; create "/myBucket"; get "/u/marti/project/test.txt" "/myBucket/test.txt"; list "/myBucket"; run;

Sorry to get a file from S3 onto SAS (now used get statement). If I do the list. It is giving the info(modified date )in the log. How can I read that into sas to work with my logic.

ex: if modified date is today then get the file onto sas otherwise no.

smantha
Lapis Lazuli | Level 10

you can add the following lines

 

proc printto log="homeopath/status.txt";

run;

 

proc s3 step;

 

proc printto;

run;

 

read the status from the status.txt

 

sathya66
Barite | Level 11
This will not work as I need to read a file in S3 bucket.
I can list all the files and modified date from S3 bucket into a dateset but how can I apply this logic in proc s3?
smantha
Lapis Lazuli | Level 10

As far as I know one cannot write an if then logic inside a proc step. You have to use two separate steps one to get status and one to read the file itself based on what you find.

ChrisNZ
Tourmaline | Level 20

Try:

Step 1: Momentarily redirect the log with proc PRINTTO

Step 2: Run proc S3 with INFO statement (or LIST? which one gives you the date?)

Step 3: Stop the redirection: run proc PRINTTO again

Step 4: Run a data steps that analyses the log file.

           This data steps triggers a new proc S3 run if the date is as expected.

sathya66
Barite | Level 11
yes, thanks
It worked.
In Step4.
I have written a macro to read the dates and files from the log dateset (call symput) and if file and date matches then do proc S3 otherwise "file is not todays file".
Thanks for your Help .

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

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 8 replies
  • 2186 views
  • 1 like
  • 3 in conversation