2012 orlandoflorida april 22-25, 2012 sometimes one needs an option with unusual dates arthur...

22
2012OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur Tabachneck Matthew Kastin Thornhill, Ontario Louisville, Colorado Xia Ke Shan Beijing, China art297 FriedEgg KSharp

Upload: lucy-cullifer

Post on 14-Dec-2015

213 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 2012 OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado

2012OrlandoFloridaApril 22-25, 2012

Sometimes one needs an optionwith unusual dates

Arthur Tabachneck Matthew KastinThornhill, Ontario Louisville,

ColoradoXia Ke Shan

Beijing, China

art297 FriedEgg

KSharp

Page 2: 2012 OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado

Sometimes one needs an optionwith unusual calendar dates

06APR2011

06JUL2011

06OCT2011

06JAN2011

05APR2012

beginning of fiscal year

start of the 4th quarter

start of the 2nd quarter

start of the 3rd quarter

end of fiscal year

Page 3: 2012 OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado

Wouldn’t it be nice to be able to automaticallyemail a correct Chanukah greeting on the right days?

       ))  || | | | | | | | ||_|_|_|_|_|_|_|_|       _|_

Page 4: 2012 OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado

       )) )  | | | | | | | | | ||_|_|_|_|_|_|_|_|       _|_

Wouldn’t it be nice to be able to automaticallyemail a correct Chanukah greeting on the right days?

Page 5: 2012 OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado

       )) ) )  || | | | | | | | ||_|_|_|_|_|_|_|_|       _|_

Wouldn’t it be nice to be able to automaticallyemail a correct Chanukah greeting on the right days?

Page 6: 2012 OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado

       )) ) ) ) || | | | | | | | ||_|_|_|_|_|_|_|_|       _|_

Wouldn’t it be nice to be able to automaticallyemail a correct Chanukah greeting on the right days?

Page 7: 2012 OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado

       )) ) ) ) | )| | | | | | | | ||_|_|_|_|_|_|_|_|       _|_

Wouldn’t it be nice to be able to automaticallyemail a correct Chanukah greeting on the right days?

Page 8: 2012 OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado

       )) ) ) ) | ) )| | | | | | | | ||_|_|_|_|_|_|_|_|       _|_

Wouldn’t it be nice to be able to automaticallyemail a correct Chanukah greeting on the right days?

Page 9: 2012 OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado

       )) ) ) ) | ) ) )| | | | | | | | ||_|_|_|_|_|_|_|_|       _|_

Wouldn’t it be nice to be able to automaticallyemail a correct Chanukah greeting on the right days?

Page 10: 2012 OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado

       )) ) ) ) | ) ) ) )| | | | | | | | ||_|_|_|_|_|_|_|_|       _|_

Wouldn’t it be nice to be able to automaticallyemail a correct Chanukah greeting on the right days?

Page 11: 2012 OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado

or automatically email Chinese New Year greetings? /^\/^\ _|__| O| \/ /~ \_/ \ \____|__________/ \ \_______ \ `\ \ \ | | \ / / \ / / \\ / / \ \ / / \ \ / / _----_ \ \ / / _-~ ~-_ | | ( ( _-~ _--_ ~-_ _/ | \ ~-____-~ _-~ ~-_ ~-_-~ / ~-_ _-~ ~-_ _-~ ~--______-~ ~-___-~

_\______ /_______ _____\/_|___ / __|_ __/_ / _|_ | | _|__|__ / / __|__ /|\ | | | \/ | / | | /\ \|

Page 12: 2012 OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado

the Islamic calendar

the Hebrew calendar

the Chinese agricultural calendar

or any calendar you want?

or conduct analyses of, or based on, dates from:

Page 13: 2012 OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado

e.g., to be able to analyze effects thatare functions of annual sporting event schedules?

Page 14: 2012 OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado

Step 1: Create interval datasetsdata fyds fqds fmds;

do begin= '06APR1900'd to '05APR2100'd;if day(begin) eq 6 then do;

mbeg=month(begin);season=max(mbeg-3,(mbeg<4)*(mbeg+9));end=intnx('month', begin, 1, 'same')-1; output fmds;if mbeg eq 4 then do;

season=year(begin);end=intnx('year', begin, 1, 'same')-1; output fyds;

end;if mbeg in (4,7,10,1) then do;

season=max(round(mbeg/4,1),(mbeg<4)*4);end=intnx('month', begin, 3, 'same')-1; output fqds;

end;end;

end;format begin end date.;

run;

Page 15: 2012 OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado

Step 2: Apply the intervalds System Option

options intervalds=(FiscalQuarter=FQDS FiscalMonth=FMDS                     FiscalYear=FYDS);

Page 16: 2012 OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado

Step 3: Use any desired interval function(s)data want (keep=date fiscal:);

set sashelp.pricedata (obs=12);format date date9.;fiscal_year=intindex( 'FiscalYear', date );fiscal_qtr=intindex( 'FiscalQuarter', date );fiscal_month=intindex( 'FiscalMonth', date );next_year_start=intnx('FiscalYear',date,1,'b');next_year_middle=intnx('FiscalYear',date,1,'m');next_year_end=intnx('FiscalYear',date,1,'e');format date next: date9.;

run;/*Note: You can also use other interval functions*/

Page 17: 2012 OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado

which will produce:

fiscal fiscal fiscal_ next_year next_year next_year date _year _qtr month _start _middle _end

01JAN98 1997 3 9 06APR98 05OCT98 05APR9901FEB98 1997 4 10 06APR98 05OCT98 05APR9901MAR98 1997 4 11 06APR98 05OCT98 05APR9901APR98 1997 4 12 06APR98 05OCT98 05APR9901MAY98 1998 1 1 06APR99 05OCT99 05APR0001JUN98 1998 1 2 06APR99 05OCT99 05APR0001JUL98 1998 1 3 06APR99 05OCT99 05APR0001AUG98 1998 2 4 06APR99 05OCT99 05APR0001SEP98 1998 2 5 06APR99 05OCT99 05APR0001OCT98 1998 2 6 06APR99 05OCT99 05APR0001NOV98 1998 3 7 06APR99 05OCT99 05APR0001DEC98 1998 3 8 06APR99 05OCT99 05APR00

Page 18: 2012 OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado

British fiscal yearsthe Hebrew calendarthe Islamic calendarthe Chinese Agricultural calendar

the NCAA March Madness tournament

hardest part is creating the interval datasetsour paper includes code that creates datasets for:

the datasets can be transferred to Google Calendar with the code in Bill Roehl’s paper, Using SAS® to Get a Date: Integrating Google Calendar’s API with SAS®

Page 19: 2012 OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado

www.sascommunity.org/wiki/Sometimes_One_Needs_an_Option_with_Unusual_Dates

All of the code and this Powerpoint can be found at:

Page 20: 2012 OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado

create functions using PROC FCMP

import data from web sites

create and use INTERVALDS datasets

The code includes examples of how to:

automatically create formats from data files

use the hash method to create lookup tables

create and send holiday email greetings

write an expanded/localized Holiday function

Page 21: 2012 OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado
Page 22: 2012 OrlandoFlorida April 22-25, 2012 Sometimes one needs an option with unusual dates Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado

Your comments and questions

are valued and encouraged

Arthur Tabachneck, Ph.D. myQNA, Inc., Thornhill, Ontario e-mail: [email protected]

Matthew Kastini-behavior, Inc., Louisville, Coloradoemail: [email protected] Ke ShanChinese Financial Electrical CompanyBeijing, Chinaemail: [email protected]