Download presentation
Presentation is loading. Please wait.
1
Automating SAS through the Power of VB Script
2
Outline VB Script Custom Log Task Scheduler
Job Streams – Daily, Weekly, Monthly Input Files Automation
3
What is VB Script? Scripting Language Automation capabilities
4
Running SAS From Command Prompt
Required SAS Location Code Location Optional Log Location Output Location
5
Running SAS From Command Prompt
“<SAS location> -sysin <code location> -print <output location> -log <log location>”
6
VB Script “<SAS location> -sysin <code location> -print <output location> -log <log location>”
7
Custom Log Creation No auto-generated log for VB Script
OpenTextFile function Log file location 1-reading, 2-writing, 8-appending True-create, false-don’t WriteLine function
8
Task Scheduler
9
Task Scheduler Required Optional General Triggers Actions Conditions
Settings
10
Task Scheduler Required Optional General Triggers Actions Conditions
Settings
11
Task Scheduler Required Optional General Triggers Actions Conditions
Settings
12
SAS Job Streams – Daily Simple %inc statement needed.
%inc 'C:\Data\Conference_Paper\Automated SAS Code\Daily\Subcode_1.sas'; %inc "C:\Data\Conference_Paper\Automated SAS Code\Daily\Subcode_2.sas"; %inc "C:\Data\Conference_Paper\Automated SAS Code\Daily\Subcode_3.sas"; Simple %inc statement needed. Can have multiple set up to run daily. As long as main code is set up to run subcodes will also run. NOTE: If your line of code contains a macro variable it will require double quotes.
13
SAS Job Streams – Weekly
%SYSFUNC – macro function that allows code to evaluate SAS functions TODAY() – SAS function will return the value of today. If no format is specified it will show the number of days since January 1, 1960 WEEKDAY() – SAS function that outputs a value from 1 to 7 for the current day of week, e.g. 4 for Wednesday
14
SAS Job Streams – Monthly
Day()- SAS function that returns the day of the month. Above code shows logic to kick off jobs on the 1st day of the month or the 26th day of the month.
15
Input Files Filename(fileref,file_name) data _null_; Fopen(fileref)
Finfo(varname,option) Today() %Macro CheckFile; data _null_; dummy=filename('fle',"C:\Data\Conference_Paper\test.txt"); fid=fopen('fle'); mdfy=finfo(fid,'Last Modified'); mdfydte=input(mdfy,datetime.); today=today()*24*60*60; if fid=0 then filesready=2; else if mdfydte >= today then filesready=1; else filesready=0; call symput('filesready', filesready); run; %mend;
16
Input Files &filesready 1=good 0=old 2=doesn’t exist
17
Input Files &filesready 1=good 0=old 2=doesn’t exist
18
Automate s SAS function FILENAME -allows SAS to send an electronically. &syscc =0 if successful &syscc =4 if there were warnings &syscc all other values if errors. creation of the &syscc_old macro variable allows jobs to continue running.
19
Automate s –Cont. Within each code you can add to:, cc:, subject: and the attachment. Put statements allow for further detail.
20
Automate Emails –Cont. Adjust config file
Config file is a text file named SASV9.CFG and will be saved in the same spot where SAS is installed config might change depending on the server used on your computer.
21
Conclusion Improve Automated Processes by:
Kick off SAS using VB script and a task scheduler Custom Log Run Daily, Weekly, and Monthly Jobs Check for input files automation
22
Contact Information Name: Lindsey Whiting Company: Kohler Co. City/State: Kohler, Wisconsin Phone: x
23
Contact Information Name: Joey Kaiser Company: Kohler Co. City/State: Kohler, Wisconsin Phone: x
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.