MASUG March 10, 2006 at FedEx. Agenda Announcements Announcements Tips & Tricks Tips & Tricks Lisa...

14
MASUG MASUG March 10, 2006 March 10, 2006 at FedEx at FedEx

Transcript of MASUG March 10, 2006 at FedEx. Agenda Announcements Announcements Tips & Tricks Tips & Tricks Lisa...

Page 1: MASUG March 10, 2006 at FedEx. Agenda Announcements Announcements Tips & Tricks Tips & Tricks Lisa Horwitz from SAS Lisa Horwitz from SAS.

MASUGMASUG

March 10, 2006March 10, 2006

at FedExat FedEx

Page 2: MASUG March 10, 2006 at FedEx. Agenda Announcements Announcements Tips & Tricks Tips & Tricks Lisa Horwitz from SAS Lisa Horwitz from SAS.

AgendaAgenda

• AnnouncementsAnnouncements

• Tips & TricksTips & Tricks

• Lisa Horwitz from SASLisa Horwitz from SAS

Page 3: MASUG March 10, 2006 at FedEx. Agenda Announcements Announcements Tips & Tricks Tips & Tricks Lisa Horwitz from SAS Lisa Horwitz from SAS.

AnnouncementsAnnouncements

• Next meeting May 2006Next meeting May 2006– Hopefully at the Doubletree on Sanderlin Hopefully at the Doubletree on Sanderlin

with beverages and snacks (tentative 5-7 with beverages and snacks (tentative 5-7 pm)pm)

– SESUG speaker topic choiceSESUG speaker topic choice

• SAS training in MemphisSAS training in Memphis– SAS makes go/no go decision 3 weeks before SAS makes go/no go decision 3 weeks before

class date so register early!class date so register early!– New location in FedEx Institute of TechnologyNew location in FedEx Institute of Technology

Page 4: MASUG March 10, 2006 at FedEx. Agenda Announcements Announcements Tips & Tricks Tips & Tricks Lisa Horwitz from SAS Lisa Horwitz from SAS.

Announcements (cont’d)Announcements (cont’d)

• Volunteers for Planning Committee?Volunteers for Planning Committee?– No experience needed and no No experience needed and no

compensation provided compensation provided

• SUGI March 26-29SUGI March 26-29– Get together at the Kickback Party?Get together at the Kickback Party?

• SESUG October 8-9 in AtlantaSESUG October 8-9 in Atlanta– Call for Papers closes April 7thCall for Papers closes April 7th

Page 5: MASUG March 10, 2006 at FedEx. Agenda Announcements Announcements Tips & Tricks Tips & Tricks Lisa Horwitz from SAS Lisa Horwitz from SAS.

Complete Automationof Routine Reports

Using Macro Variables

Memphis Area SAS Users GroupFriday, March 10, 2006

Michael Bates, Risk AnalystFirst Horizon National Corporation

(901) [email protected]

Page 6: MASUG March 10, 2006 at FedEx. Agenda Announcements Announcements Tips & Tricks Tips & Tricks Lisa Horwitz from SAS Lisa Horwitz from SAS.

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

Page 7: MASUG March 10, 2006 at FedEx. Agenda Announcements Announcements Tips & Tricks Tips & Tricks Lisa Horwitz from SAS Lisa Horwitz from SAS.

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

Page 8: MASUG March 10, 2006 at FedEx. Agenda Announcements Announcements Tips & Tricks Tips & Tricks Lisa Horwitz from SAS Lisa Horwitz from SAS.

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

Page 9: MASUG March 10, 2006 at FedEx. Agenda Announcements Announcements Tips & Tricks Tips & Tricks Lisa Horwitz from SAS Lisa Horwitz from SAS.

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

Page 10: MASUG March 10, 2006 at FedEx. Agenda Announcements Announcements Tips & Tricks Tips & Tricks Lisa Horwitz from SAS Lisa Horwitz from SAS.

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

Page 11: MASUG March 10, 2006 at FedEx. Agenda Announcements Announcements Tips & Tricks Tips & Tricks Lisa Horwitz from SAS Lisa Horwitz from SAS.

Useful Date FunctionsDATDIF Returns the number of days between two dates DATE Returns the current date as a SAS date value DATEJUL Converts a Julian date to a SAS date value DATEPART Extracts the date from a SAS datetime value DATETIME Returns the current date and time of day as a SAS datetime value DAY Returns the day of the month from a SAS date value DHMS Returns a SAS datetime value from date, hour, minute, and second HMS Returns a SAS time value from hour, minute, and second values HOUR Returns the hour from a SAS time or datetime value INTCK Returns the integer count of the number of interval boundaries

between two dates, two times, or two datetime valuesINTNX Increments a date, time, or datetime value by a given interval or

intervals, and returns a date, time, or datetime valueJULDATE Returns the Julian date from a SAS date value JULDATE7 Returns a seven-digit Julian date from a SAS date value MDY Returns a SAS date value from month, day, and year values MINUTE Returns the minute from a SAS time or datetime value MONTH Returns the month from a SAS date value NLDATE Converts the SAS date value to the date value of the specified

locale using the date-format modifiers NLDATM Converts the SAS datetime values to the time value of the specified

locale using the datetime format modifiersNLTIME Converts the SAS time or datetime value to the time value of the specified

locale using the time-format modifiersQTR Returns the quarter of the year from a SAS date value SECOND Returns the second from a SAS time or datetime value TIME Returns the current time of day TIMEPART Extracts a time value from a SAS datetime value TODAY Returns the current date as a SAS date value WEEK Returns the week number value WEEKDAY Returns the day of the week from a SAS date value YEAR Returns the year from a SAS date value YRDIF Returns the difference in years between two dates YYQ Returns a SAS date value from the year and quarter

Page 12: MASUG March 10, 2006 at FedEx. Agenda Announcements Announcements Tips & Tricks Tips & Tricks Lisa Horwitz from SAS Lisa Horwitz from SAS.

Useful Date Formatsddmmyy5. 24/12 mmddyyn8. 10222005 yymmdd10. 2005-04-03ddmmyy6. 241205 mmyy5. 10M05 yymmddc5. 05:10ddmmyy7. 241205 mmyy6. 10M05 yymmddd8. 05-10-22ddmmyy8. 24/12/05 mmyy. 10M2005 yymmddp10. 2005.10.22ddmmyy10. 24/12/2005 mmyy7. 10M2005 yymmddn8. 20051022date5. 16MAR mmyy10. 10M2005 yymmc5. 05:07date6. 16MAR mmyyc5. 07:05 yymmd. 2005-07date7. 16MAR03 mmyyd. 07-2005 yymmn4. 0507date8. 16MAR03 mmyyn4. 0705 yymmp8. 2005.07date9. 16MAR2003 mmyyp8. 07.2005 yymms10. 2005/07ddmmyyc5. 16:03 mmyys10. 07/2005 yymm5. 05M10ddmmyyd8. 16-03-05 monname1. M yymm6. 05M10ddmmyyp10. 16.03.2005 monname3. Mar yymm. 2005M10ddmmyyn8. 16032005 monname5. March yymm7. 2005M10mmddyy2. 10 month. 11 yymm10. 2005M10mmddyy3. 10 monyy5. DEC05 yymon6. 05JUNmmddyy4. 1025 monyy7. DEC2005 yymon7. 2005JUNmmddyy5. 10/25 year2. 05 yyq4. 05Q2mmddyy6. 102505 year4. 2005 yyq6. 2005Q2mmddyy7. 102505 yymmdd2. 05 yyq10. 2005Q2mmddyy8. 10/25/05 yymmdd3. 05 yyqc4. 05:3mmddyy10. 10/25/2005 yymmdd4. 0504 yyqd. 2005-3mmddyyc5. 10:22 yymmdd5. 05-04 yyqn3. 053mmddyyd8. 10-22-05 yymmdd6. 050403 yyqp6. 2005.3mmddyyp10. 10.22.2005 yymmdd7. 050403 yyqs8. 2005/3

yymmdd8. 05-04-03

Page 13: MASUG March 10, 2006 at FedEx. Agenda Announcements Announcements Tips & Tricks Tips & Tricks Lisa Horwitz from SAS Lisa Horwitz from SAS.

Useful DateTime Formats

datetime. 10NOV05:03:49:19datetime7. 10NOV05dtdate. 16APR00dtdate9. 16APR2000dtmonyy. OCT06dtmonyy5. OCT06dtmonyy6. OCT06dtmonyy7. OCT2006dtwkdatx. Monday, 16 October 2006dtwkdatx3. Mondtwkdatx8. Mondtwkdatx25. Monday, 16 Oct 2006dtyear. 2006dtyear2. 06dtyear3. 06year4. 2006

Page 14: MASUG March 10, 2006 at FedEx. Agenda Announcements Announcements Tips & Tricks Tips & Tricks Lisa Horwitz from SAS Lisa Horwitz from SAS.

Lisa HorwitzLisa Horwitz

Systems Engineer Manager Systems Engineer Manager for SAS for SAS