140 likes | 325 Views
MASUG. March 10, 2006 at FedEx. Agenda. Announcements Tips & Tricks Lisa Horwitz from SAS. Announcements. Next meeting May 2006 Hopefully at the Doubletree on Sanderlin with beverages and snacks (tentative 5-7 pm) SESUG speaker topic choice SAS training in Memphis
E N D
MASUG March 10, 2006 at FedEx
Agenda • Announcements • Tips & Tricks • Lisa Horwitz from SAS
Announcements • Next meeting May 2006 • Hopefully at the Doubletree on Sanderlin with beverages and snacks (tentative 5-7 pm) • SESUG speaker topic choice • SAS training in Memphis • SAS makes go/no go decision 3 weeks before class date so register early! • New location in FedEx Institute of Technology
Announcements (cont’d) • Volunteers for Planning Committee? • No experience needed and no compensation provided • SUGI March 26-29 • Get together at the Kickback Party? • SESUG October 8-9 in Atlanta • Call for Papers closes April 7th
Complete Automationof Routine ReportsUsing Macro VariablesMemphis Area SAS Users GroupFriday, March 10, 2006 Michael Bates, Risk Analyst First Horizon National Corporation (901) 257-6038 mwbates@firsthorizon.com
Goal • Submit a routine SAS job, in a open session or in a scheduled queue, with no user input needed Why ? • Eliminate user error • Easily pass reports on to others
Determining Appropriate Time Frame • Today’s Date Log • %let tdy = %sysfunc(today()); 1 %let tdy = %sysfunc(today()); • %put tdy = &tdy.; 2 %put tdy = &tdy.; • tdy = 16862 • This Year Log • %let mnth = %sysfunc(month(&tdy.)); 3 %let mnth = %sysfunc(month(&tdy.)); • %put mnth = &mnth.; 4 %put mnth = &mnth.; • mnth = 3 • This Month Log • %let yr = %sysfunc(year(&tdy.)); 5 %let yr = %sysfunc(year(&tdy.)); • %put yr = &yr.; 6 %put yr = &yr.; • yr = 2006 • This Week Log • %let wk = %sysfunc(week(&tdy.)); 7 %let wk = %sysfunc(week(&tdy.)); • %put wk = &wk.; 8 %put wk = &wk.; • wk = 9 • Last Month Log • %let l_mnth = %eval(&mnth. - 1); 9 %let l_mnth = %eval(&mnth. - 1); • %put l_mnth = &l_mnth.; 10 %put l_mnth = &l_mnth.; • l_mnth = 2
Converting Into Date Format • Date • %let d_date = %sysfunc(mdy(&mnth.,1,&yr.),date9.); • %put d_date = &d_date.; • Log • 11 %let d_date = %sysfunc(mdy(&mnth.,1,&yr.),date9.); • 12 %put d_date = &d_date.; • d_date = 01MAR2006 • DateTime • %let dt_date = %sysfunc(mdy(&mnth.,1,&yr.),date9.):00:00:00; • %put dt_date = &dt_date.; • Log • 13 %let dt_date = %sysfunc(mdy(&mnth.,1,&yr.),date9.):00:00:00; • 14 %put dt_date = &dt_date.; • dt_date = 01MAR2006:00:00:00
Running a job at a given time • Job can't run until 3rd of the month at 2:30pm • %let launch1 = %sysfunc(mdy(%sysfunc(month(%eval(&tdy.+30))),3, • %sysfunc(year(%eval(&tdy.+30)))),date9.):14:30:00; • %put launch1 = &launch1; • data_null_; • slept = wakeup("&launch1."dt); • run; • Log • 15 %let launch1 = %sysfunc(mdy(%sysfunc(month(%eval(&tdy.+30))),3, • 16 %sysfunc(year(%eval(&tdy.+30)))),date9.):14:30:00; • 17 %put launch1 = &launch1; • launch1 = 03APR2006:14:30:00 • Job can't run until Sunday at 8:00am • %let launch2 = %sysfunc(mdy( • sysfunc(month(%eval(&tdy. + %eval(((%sysfunc(weekday(&tdy.))) - 8) * -1)))), • sysfunc(day(%eval(&tdy. + %eval(((%sysfunc(weekday(&tdy.))) - 8) * -1)))), • sysfunc(year(%eval(&tdy. + %eval(((%sysfunc(weekday(&tdy.))) - 8) * -1))))), • date9.):08:00:00;; • %put launch2 = &launch2; • data_null_; • slept = wakeup("&launch2."dt); • run; • Log • 18 %let launch2 = %sysfunc(mdy( • 23 %sysfunc(month(%eval(&tdy. + %eval(((%sysfunc(weekday(&tdy.))) - 8) * -1)))), • 24 %sysfunc(day(%eval(&tdy. + %eval(((%sysfunc(weekday(&tdy.))) - 8) * -1)))), • 25 %sysfunc(year(%eval(&tdy. + %eval(((%sysfunc(weekday(&tdy.))) - 8) * -1))))), • 26 date9.):08:00:00; • 27 %put launch2 = &launch2; • launch2 = 12MAR2006:08:00:00
Customizing Output • File Names • %let mon_yr_nm = %sysfunc(mdy(&mnth.,1,&yr.),monyy5.); • %put mon_yr_nm = &mon_yr_nm.; • Log • 28 %let mon_yr_nm = %sysfunc(mdy(&mnth.,1,&yr.),monyy5.); • 29 %put mon_yr_nm = &mon_yr_nm.; • mon_yr_nm = MAR06 • DDE Column Or Row Selection • %let col = %eval((((&yr. - 2000) * 12) + &mnth.) - 74); • %put col = &col.; • Log • 30 %let col = %eval((((&yr. - 2000) * 12) + &mnth.) - 74); • 31 %put col = &col.; • col = 1 • DDE Column Or Row Headings • %let col_name = %sysfunc(mdy(&mnth.,1,&yr.),monname9.); • %put col_name = &col_name.; • Log • 32 %let col_name = %sysfunc(mdy(&mnth.,1,&yr.),monname9.); • 33 %put col_name = &col_name.; • col_name = March
Lisa Horwitz Systems Engineer Manager for SAS