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

Sometimes one needs an option with unusual dates

  • Upload
    kerryn

  • View
    41

  • Download
    0

Embed Size (px)

DESCRIPTION

Sometimes one needs an option with unusual dates. Arthur TabachneckMatthew Kastin Thornhill, OntarioLouisville, Colorado. art297 FriedEgg KSharp. Xia Ke Shan Beijing, China. 2012 Orlando Florida April 22-25, 2012. - PowerPoint PPT Presentation

Citation preview

Page 1: Sometimes one needs an option with unusual dates

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: Sometimes one needs an option with unusual dates

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: Sometimes one needs an option with unusual dates

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

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

Page 4: Sometimes one needs an option with unusual dates

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

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

Page 5: Sometimes one needs an option with unusual dates

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

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

Page 6: Sometimes one needs an option with unusual dates

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

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

Page 7: Sometimes one needs an option with unusual dates

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

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

Page 8: Sometimes one needs an option with unusual dates

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

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

Page 9: Sometimes one needs an option with unusual dates

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

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

Page 10: Sometimes one needs an option with unusual dates

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

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

Page 11: Sometimes one needs an option with unusual dates

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

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

Page 12: Sometimes one needs an option with unusual dates

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: Sometimes one needs an option with unusual dates

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

Page 14: Sometimes one needs an option with unusual dates

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: Sometimes one needs an option with unusual dates

Step 2: Apply the intervalds System Option

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

Page 16: Sometimes one needs an option with unusual dates

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: Sometimes one needs an option with unusual dates

which will produce: fiscal fiscal fiscal_ next_year next_year next_year date _year _qtr month _start _middle _end01JAN98 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: Sometimes one needs an option with unusual dates

British fiscal yearsthe Hebrew calendarthe Islamic calendarthe Chinese Agricultural calendarthe 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: Sometimes one needs an option with unusual dates

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: Sometimes one needs an option with unusual dates

create functions using PROC FCMP

import data from web sitescreate 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 greetingswrite an expanded/localized Holiday function

Page 21: Sometimes one needs an option with unusual dates
Page 22: Sometimes one needs an option with unusual dates

Your comments and questions

are valued and encouraged

Arthur Tabachneck, Ph.D. myQNA, Inc., Thornhill, Ontario e-mail: [email protected] Kastini-behavior, Inc., Louisville, Coloradoemail: [email protected] Ke ShanChinese Financial Electrical CompanyBeijing, Chinaemail: [email protected]