how to use sas to schedule your jobs: part ii group presentations... · how to use sas to schedule...

20
How to Use SAS to Schedule Your Jobs: Part II Keith Flysak September 20, 2017

Upload: others

Post on 21-Mar-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

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

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

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

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

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

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

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

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

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

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

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

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

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

#!/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

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

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

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

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

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

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

Questions?