BookmarkSubscribeRSS Feed
SasStatistics
Pyrite | Level 9

Assume I have created a program that includes different files to run for different days. I would like this program to run automatically, for instance every day 14.00. Since I have created this program to produce some output (for example creating a customer list) I would like the user (for instance a sales person) to be able to manually change which days he wants to receive this list (since the sales person is not a SAS programmer, it would be nice if he for instance could change the days through an Excel file say (or something else that does not require technical/programming skills) ). 

 

I demonstrate by example: 

 

* My Pseudo Program, not detailed but hopefully conveying the main ideas; 

* First I create a variable for todays date; 
data null_;
	Todays_Date = put(today(),date9.);
        call symput("Todays_Date", Todays_Date);
run; 

%If Todays_Date = 2021-06-21 %then %do; 
  %include "Some Random Program that will produce an export file";
%end; 

%If Todays_Date = 2021-06-15 %then %do; 
  %include "Some Random Program 2 that will produce an export file";
%end; 

So the question is: 

 

 

1. How can I get this program to for instance run automatically evry day (or evry month for instance) at 14.00? 

 

2. Now the program runs evry day, and the sales person will conact me for next month and Ask: "Can you change so that the program "Some Random Program" is ran 2021-07-14 [instead of 2021-06-21] for the uppcoming month"? Ideally, the user should be able to change this himself without going into SAS (in reality, the program is far much more complex than the pseudo program demonstrated here). 


All advice appreciated. 

4 REPLIES 4
yabwon
Onyx | Level 15

For everyday scheduling under Linux/UNIX try to use: https://en.wikipedia.org/wiki/Cron

If user can put the file somewhere on the network you can use `filename URL` to get it and then extract the date.

 

B.

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



SasStatistics
Pyrite | Level 9
Linux is used. The user can put the file on the network, can you be more specific about: "you can use `filename URL` to get it and then extract the date."?
Thanks.
yabwon
Onyx | Level 15

Assuming that 

 

www.some.address.on.net/file.xlsx

is the location of the excel file (in fact a text file with the date would be even more convenient)

you can do something like this:

 

filename in URL "www.some.address.on.net/file.xlsx" lrecl=1 recfm=n;
filename out URL "%susfunc(pathname(work))/file.xlsx" lrecl=1 recfm=n;

data _null_;
  rc = fcopy("in","out");
  if rc then put "ERROR!";
run;

filename in clear;
filename out clear;

proc import path = "%susfunc(pathname(work))/file.xlsx";
<...>
run;

<...>

If the file would be a text file with just date:

filename in URL "www.some.address.on.net/file.txt";

data _null_;
  infile in;
  input date anydatea.;
  call sumputx("date", put(date, yymmdd10.), "G");
run;

filename in clear;

Of course you will have to add some "defensive" code, like testing if file exist, testing if date is propper, etc.

 

All the best

Bart

 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



SASKiwi
PROC Star

@SasStatistics  - Scheduling is also available via SAS Management Console. Talk to your SAS administrator to find out more.

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!

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.

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
  • 4 replies
  • 574 views
  • 2 likes
  • 3 in conversation