How to Use SAS to Schedule Your Jobs: Part II Group Presentations... · How to Use SAS to Schedule...
Transcript of How to Use SAS to Schedule Your Jobs: Part II Group Presentations... · How to Use SAS to Schedule...
![Page 1: How to Use SAS to Schedule Your Jobs: Part II Group Presentations... · How to Use SAS to Schedule Your Jobs: Part II Keith Flysak September 20, 2017](https://reader030.fdocuments.us/reader030/viewer/2022040907/5e7e7a9fd2b30d737c2b928b/html5/thumbnails/1.jpg)
How to Use SAS to Schedule Your Jobs: Part II
Keith Flysak
September 20, 2017
![Page 2: How to Use SAS to Schedule Your Jobs: Part II Group Presentations... · How to Use SAS to Schedule Your Jobs: Part II Keith Flysak September 20, 2017](https://reader030.fdocuments.us/reader030/viewer/2022040907/5e7e7a9fd2b30d737c2b928b/html5/thumbnails/2.jpg)
Outline
• High level requirements
• Example query/report
• Saving, or moving, the file to the server
• Creating the shell script
• Scheduling the shell script
![Page 3: How to Use SAS to Schedule Your Jobs: Part II Group Presentations... · How to Use SAS to Schedule Your Jobs: Part II Keith Flysak September 20, 2017](https://reader030.fdocuments.us/reader030/viewer/2022040907/5e7e7a9fd2b30d737c2b928b/html5/thumbnails/3.jpg)
High Level Requirements
• SAS Server Installation– On a machine running Unix
• Terminal emulator (PuTTY)
• FTP Client (WinSCP)
• A patient System Administrator– For example, they may need to assist you with
setting up a personal directory
– Maybe some other Unix stuff
– Maybe a lot of other Unix stuff
![Page 4: How to Use SAS to Schedule Your Jobs: Part II Group Presentations... · How to Use SAS to Schedule Your Jobs: Part II Keith Flysak September 20, 2017](https://reader030.fdocuments.us/reader030/viewer/2022040907/5e7e7a9fd2b30d737c2b928b/html5/thumbnails/4.jpg)
Creating a Dataset and Report
![Page 5: How to Use SAS to Schedule Your Jobs: Part II Group Presentations... · How to Use SAS to Schedule Your Jobs: Part II Keith Flysak September 20, 2017](https://reader030.fdocuments.us/reader030/viewer/2022040907/5e7e7a9fd2b30d737c2b928b/html5/thumbnails/5.jpg)
Creating a Dataset
PROC SQL;
CREATE TABLE dataset AS
SELECT presenter_no,
presenter,
presentation_dt
FROM presentations;
QUIT;
![Page 6: How to Use SAS to Schedule Your Jobs: Part II Group Presentations... · How to Use SAS to Schedule Your Jobs: Part II Keith Flysak September 20, 2017](https://reader030.fdocuments.us/reader030/viewer/2022040907/5e7e7a9fd2b30d737c2b928b/html5/thumbnails/6.jpg)
Printing the Report
ODS HTML BODY='/sas/home/keith/export/index.html'(TITLE="Demonstration for SAS“) STYLE=HTMLBlue;
PROC REPORT DATA=dataset;TITLE1 'Demonstration for Regina User Group‘;TITLE2 "Last updated: " %sysfunc(date(), WORDDATE) "at" &theTime;TITLE5 "List of Presenters“;DEFINE presenter_no / ‘Presenter Number‘;DEFINE presenter / 'Presenter Name‘;DEFINE presentation_dt / 'Presentation Date';
RUN;
DATA _null_ ;IF nobs = 0 THEN DO;
FILE PRINT;PUT 'No presentations have occurred today today';
END;STOP;
SET dataset nobs=nobs;RUN;
ODS HTML CLOSE;
![Page 7: How to Use SAS to Schedule Your Jobs: Part II Group Presentations... · How to Use SAS to Schedule Your Jobs: Part II Keith Flysak September 20, 2017](https://reader030.fdocuments.us/reader030/viewer/2022040907/5e7e7a9fd2b30d737c2b928b/html5/thumbnails/7.jpg)
Example Report Output
• Report before it runs
• Report after it runs
![Page 8: How to Use SAS to Schedule Your Jobs: Part II Group Presentations... · How to Use SAS to Schedule Your Jobs: Part II Keith Flysak September 20, 2017](https://reader030.fdocuments.us/reader030/viewer/2022040907/5e7e7a9fd2b30d737c2b928b/html5/thumbnails/8.jpg)
Saving or Moving Your Query
![Page 9: How to Use SAS to Schedule Your Jobs: Part II Group Presentations... · How to Use SAS to Schedule Your Jobs: Part II Keith Flysak September 20, 2017](https://reader030.fdocuments.us/reader030/viewer/2022040907/5e7e7a9fd2b30d737c2b928b/html5/thumbnails/9.jpg)
Saving/Moving Program to the Server
• The SAS code must be moved to the server before it can be scheduled to run.
• There are a couple ways to do this:
– Right-clicking code and saving the .sas file on the server in Enterprise Guide
– Using FTP (WinSCP)
![Page 10: How to Use SAS to Schedule Your Jobs: Part II Group Presentations... · How to Use SAS to Schedule Your Jobs: Part II Keith Flysak September 20, 2017](https://reader030.fdocuments.us/reader030/viewer/2022040907/5e7e7a9fd2b30d737c2b928b/html5/thumbnails/10.jpg)
With Enterprise Guide
![Page 11: How to Use SAS to Schedule Your Jobs: Part II Group Presentations... · How to Use SAS to Schedule Your Jobs: Part II Keith Flysak September 20, 2017](https://reader030.fdocuments.us/reader030/viewer/2022040907/5e7e7a9fd2b30d737c2b928b/html5/thumbnails/11.jpg)
With WinSCP
Image from: https://winscp.net/pad/screenshot.png
![Page 12: How to Use SAS to Schedule Your Jobs: Part II Group Presentations... · How to Use SAS to Schedule Your Jobs: Part II Keith Flysak September 20, 2017](https://reader030.fdocuments.us/reader030/viewer/2022040907/5e7e7a9fd2b30d737c2b928b/html5/thumbnails/12.jpg)
Creating a Shell Script
![Page 13: How to Use SAS to Schedule Your Jobs: Part II Group Presentations... · How to Use SAS to Schedule Your Jobs: Part II Keith Flysak September 20, 2017](https://reader030.fdocuments.us/reader030/viewer/2022040907/5e7e7a9fd2b30d737c2b928b/html5/thumbnails/13.jpg)
#!/bin/ksh#######################################################
LD_LIBRARY_PATH=/your/sysadmin/knows/this/partexport LD_LIBRARY_PATH
echo "Change directory to: /sas/home/keith/export/demo/"
cd /sas/home/keith/export/demo/
echo "Run code"
/appl/SAS/SASFoundation/9.4/sasexe/sas demo.sas
echo "Complete"
![Page 14: How to Use SAS to Schedule Your Jobs: Part II Group Presentations... · How to Use SAS to Schedule Your Jobs: Part II Keith Flysak September 20, 2017](https://reader030.fdocuments.us/reader030/viewer/2022040907/5e7e7a9fd2b30d737c2b928b/html5/thumbnails/14.jpg)
Scheduling the Shell Script
![Page 15: How to Use SAS to Schedule Your Jobs: Part II Group Presentations... · How to Use SAS to Schedule Your Jobs: Part II Keith Flysak September 20, 2017](https://reader030.fdocuments.us/reader030/viewer/2022040907/5e7e7a9fd2b30d737c2b928b/html5/thumbnails/15.jpg)
Logging into SAS with PuTTY
![Page 16: How to Use SAS to Schedule Your Jobs: Part II Group Presentations... · How to Use SAS to Schedule Your Jobs: Part II Keith Flysak September 20, 2017](https://reader030.fdocuments.us/reader030/viewer/2022040907/5e7e7a9fd2b30d737c2b928b/html5/thumbnails/16.jpg)
Logging into SAS with PuTTY
![Page 17: How to Use SAS to Schedule Your Jobs: Part II Group Presentations... · How to Use SAS to Schedule Your Jobs: Part II Keith Flysak September 20, 2017](https://reader030.fdocuments.us/reader030/viewer/2022040907/5e7e7a9fd2b30d737c2b928b/html5/thumbnails/17.jpg)
Creating a Crontab
• Once logged into the SAS Server in PuTTY the command crontab –e allows me to create a crontab entry.
• Vi is the default editor in our environment.
![Page 18: How to Use SAS to Schedule Your Jobs: Part II Group Presentations... · How to Use SAS to Schedule Your Jobs: Part II Keith Flysak September 20, 2017](https://reader030.fdocuments.us/reader030/viewer/2022040907/5e7e7a9fd2b30d737c2b928b/html5/thumbnails/18.jpg)
Creating a Crontab
* * * * * /sas/home/keith/export/demo/script.sh
30 * * * 1-5 /sas/home/keith/export/demo/script.sh
0 0 1 * * /sas/home/keith/export/demo/script.sh
![Page 19: How to Use SAS to Schedule Your Jobs: Part II Group Presentations... · How to Use SAS to Schedule Your Jobs: Part II Keith Flysak September 20, 2017](https://reader030.fdocuments.us/reader030/viewer/2022040907/5e7e7a9fd2b30d737c2b928b/html5/thumbnails/19.jpg)
Granting Permission
• You will need to grant cron permission to run your script
![Page 20: How to Use SAS to Schedule Your Jobs: Part II Group Presentations... · How to Use SAS to Schedule Your Jobs: Part II Keith Flysak September 20, 2017](https://reader030.fdocuments.us/reader030/viewer/2022040907/5e7e7a9fd2b30d737c2b928b/html5/thumbnails/20.jpg)
Questions?