70
1 Working With SAS ® System Date and Time Functions Andrew H. Karp Sierra Information Services, Inc. 19229 Sonoma Highway PMB 264 Sonoma, California 95476  Andrew@SierraInfor mation.com www.SierraInformation.com

DateAndTime.pdf

Embed Size (px)

Citation preview

Page 1: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 1/70

Page 2: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 2/70

Page 3: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 3/70

Page 4: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 4/70

Page 5: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 5/70

Page 6: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 6/70

Page 7: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 7/70

Page 8: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 8/70

Page 9: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 9/70

Page 10: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 10/70

Page 11: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 11/70

Page 12: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 12/70

Page 13: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 13/70

Page 14: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 14/70

Page 15: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 15/70

Page 16: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 16/70

Page 17: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 17/70

Page 18: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 18/70

Page 19: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 19/70

Page 20: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 20/70

Page 21: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 21/70

Page 22: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 22/70

Page 23: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 23/70

Page 24: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 24/70

Page 25: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 25/70

Page 26: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 26/70

Page 27: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 27/70

Page 28: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 28/70

Page 29: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 29/70

Page 30: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 30/70

Page 31: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 31/70

Page 32: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 32/70

Page 33: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 33/70

33SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

The INTNX Function

Creates a SAS date, time or datetime value that is

a given number of time intervals from a startingvalue

INTNX(‘interval’, from,to )Example : on what date should a postcard be sent to the

parents of a newborn asking them to schedule a three-month well-baby exam, three months after the child’sbirthday (BDATE)?

MAILDATE = INTNX (‘month’,BDATE,3)the result is a SAS date variable representing the first day of

the month which is three months past the child’s birthday

Page 34: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 34/70

34SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

The INTNX Function:Enhancements in Release 6.11

By default, the INTNX Function will return a SASdate value representing the beginning date of theinterval supplied in the first argument.

Starting in Release 6.11 , the INTNX Function containsoptions which allow you to specify the alignment of theinterval.

The alignment arguments are:

END Aligns date to the end

MIDDLE Aligns date to the midpoint BEGINNING Default alignment

Page 35: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 35/70

35SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Why are the New AlignmentOperators So Useful?

Suppose we want to create a SAS datevariable representing the last day of themonth in which a transaction occurred.Since there are some months with 30days, others with 31 days and onemonth with either 28 or 29 days, a datastep approach is tedious and time

consuming.

Page 36: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 36/70

36SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Determining the Last Day of theMonth via the Data Step

112 data _null_;

113 trans_date = '15oct2002'd;114115 if month(trans_date) in (9,4,6,11) then116 trans_month = mdy( month(trans_date),30,year(trans_date) );117118 else if month(trans_date) = 2 then119 trans_month = mdy( month(trans_date),28,year(trans_date) );120121 else trans_month =

mdy( month(trans_date),31,year(trans_date) );122

123 format trans_month mmddyy10.;124125 put 'TRANSACTION MONTH:' trans_month;126127 run;

TRANSACTION MONTH:10/31/2002

Page 37: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 37/70

37SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Using the New Alignment Intervalsin the INTNX Function

Example: Create a SAS date valuerepresenting the last day of the month inwhich a transaction occurred

We want to then count the total number of

transactions that occurred in that monthTwo approaches:

Using the INTNX Function and subtractionUsing the INTNX Function and the END alignmentargument

Page 38: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 38/70

38SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Using the New Alignment Intervalsin the INTNX Function

98 Data _null_;99 transaction_date = '21oct1999'd;

100 last_day_of_month_1 = intnx('month',transaction_date,1)-1;

101 last_day_of_month_2 = intnx('month',transaction_date,0,'end');

102 format transaction_date last_Day_of_month_1last_day_of_month_2 mmddyy10.;

103 put transaction_date last_day_of_month_1 last_day_of_month_2;

104 run;

10/21/1999 10/31/1999 10/31/1999NOTE: DATA statement used:

real time 0.04 seconds

Page 39: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 39/70

39SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Using PROC EXPAND withSAS Date Variables

Very useful procedure for working withdata collected in the time domainIn the SAS/ETS module

Substantial enhancements in Releases 6.06and 6.12 of SAS/ETS software

creates SAS data sets

Page 40: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 40/70

40SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Using PROC EXPAND withData Forming a Time Series

Replaces missing values in a time seriesapplies a cubic spline function is apply to obtain thecontinuous time approximation of the missing values to bereplaced

Aggregates data from a higher to a lower

sampling frequency (e.g., daily to monthly)By default, missing value replacement is carried out onobservations before aggregation

Interpolates data from a lower to a highersampling frequency (e.g., monthly to daily)

By default, missing value replacement is carried out onobservations before interpolation

Page 41: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 41/70

Page 42: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 42/70

42SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Using PROC EXPAND withData Forming a Time Series

Benefits to using PROC EXPANDClean up your series before applyingother procedures to it

Avoid data step manipulation of a seriesprior to aggregation or interpolationEliminate tedious data step coding forcomplex inter-observation handling of timeseries values

Page 43: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 43/70

43SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Two ProblemsHow can we

Round the values interpolated by PROCEXPAND?

Solution: TRANSFORMOUT Option

Change the weekly series start day fromSunday to Monday?Solution: Use SAS Date Alignment Operators

Page 44: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 44/70

44SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Solutions

proc expand data=sasclass.carmissobserved = total out=weekly

from = monthto = week.2;

id date;convert cars = weekly/transformout=(ceil);run ;

Page 45: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 45/70

Page 46: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 46/70

46SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Another Example of SAS DateAlignment Operators

SAS Date Alignment Operators areDocumented in the SAS/ETS SoftwareManual

Example: Align a monthly series to a fiscal

year starting in June

Page 47: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 47/70

47SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Another Example of SAS DateAlignment Operatorsods date number;ods listing close;ods rtf file = 'c:\reporting classes 2003\expand.rtf'

style = analysis bodytitle;* calendar vs. fiscal year aggregation;

proc expand data=sasclass.carmissfrom = month to = year out = cal_year;

id date;convert cars = cal_year/transformout=(ceil);run ;proc print data=cal_year;format cal_year comma12.;title1 'PROC EXPAND';title2 'Aggregation from Month to Calendar Year';

title3 'Default Missing Value Replacement';title4 'CEIL Transformation Operator Used to Round Results';run ;

Page 48: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 48/70

Page 49: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 49/70

49SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Another Example of SAS DateAlignment Operatorsproc expand data=sasclass.carmiss

from = month to = year.6

out = fiscal_year;id date;convert cars = fiscal_year/transformout=(ceil);run ;

proc print data=fiscal_year label split = '/';label fiscal_year = 'Fiscal/Year/Starting in June';format fiscal_year comma12.;title1 'PROC EXPAND';title2 'Aggregation from Month to Fiscal Year Starting in June';title3 'Default Missing Value Replacement';title4 'CEIL Transformation Operator Used to Round Results';

run ;ods rtf close;ods listing;

Page 50: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 50/70

50SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Another Example of SAS DateAlignment Operators

PROC EXPANDAggregation from Month to Fiscal Year Starting in June

Default Missing Value ReplacementCEIL Transformation Operator Used to Round Results

38 515UN20026

42 941UN20015

38 333UN2000

4

39 144UN19993

35 619UN1998

55 833UN1997

Fiscal YearStarting in JuneATEbs

Page 51: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 51/70

51SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Understanding the YEARCUTOFFSAS System Option

Specifies the first year of the 100-year spanthat is used to determine the century of atwo-digit year

Valid values are from 1582 to 19990

Not supported in Version 5 or Release 6.03/6.04Default value is 1900 in Version 6In Version 8 and SAS 9 the “shipped default”value is 1920

Page 52: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 52/70

Page 53: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 53/70

53SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Version 8 EnhancementsDATDIF and YRDIF Functions

Returns the number of days (DATDIF) oryears (YRDIF) between two dates.Similar to the INTCK Function

But, behavior is differentMore options

Page 54: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 54/70

54SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Version 8 EnhancementsDATDIF(start_date,end_date,basis)YRDIF(start_date,end_date,basis)

Start_date: period start dateEnd_date: period end date (not included in thecalculations)

Y e a r s = a c t u a l # o f d a y s / 3 6 5 d a y y e a r Act/365 (YRDIF Only)

Y e a r s = a c t u a l # o f d a y s / 3 6 0 d a y y e a r Act/360 (YRDIFOnly)

A s s u m e s 3 0 d a y m o n t h s a n d 3 6 0 d a y y e a r s 30/360

S a m e a s A c t / A c t Actual

U s e s a c t u a l n u m b e r o f d a y s Act/Act

R e s u l t B A S I S

Page 55: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 55/70

55SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Version 8 Enhancementsdata years;

start = '18dec1956'd;

stop = '31oct2001'd;

intyears = intck('year',start,stop);

approxyears = (stop-start)/365.25;difyears_act = yrdif(start,stop,'actual');

difyears_360 = yrdif(start,stop,'act/360');

difyears_365 = yrdif(start,stop,'act/365');

* put it in the sas log;put start = stop= ;

put intyears= approxyears= ;

put difyears_act = difyears_360 = difyears_365 = ;

run;

Page 56: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 56/70

56SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Version 8 Enhancements

start=-1109

stop=15628intyears=46approxyears=45.823408624difyears_act=45.824552736difyears_360=46.491666667difyears_365=45.854794521

The YEARDIF Function

Page 57: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 57/70

57SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Version 8 EnhancementsThe separator character can now be

specified with theDDMMYYMMDDYY

YYMMDD Formats

Page 58: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 58/70

58SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Version 8 Enhancementsdata x;

nov5 = '05nov2001'd;

put nov5 mmddyy10. ;

put B nov5 mmddyy b 10. ;

put C nov5 mmddyy c 10. ;

put P nov5 mmddyy p 10. ;run;

Page 59: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 59/70

59SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Version 8 Enhancements969 nov5 = '05nov2001'd;

970 put nov5 mmddyy10.;971 put B nov5 mmddyyb10.;

972 put C nov5 mmddyyc10.;

973 put P nov5 mmddyyp10.;

974 run;

11/05/2001

B 11 05 2001

C 11:05:2001P 11.05.2001

Page 60: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 60/70

60SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Version 8 EnhancementsNew Date Formats in Release 8.2

DTWKDATXDisplays the Weekday, Month, Day and Year of aDatetime Variable

DTDATE

Displays the Day, Month and Year of a DatetimeVariable

Eliminate the need to use the DATEPARTfunction in the Data Step to “extract” thedate “part” from a SAS datetime variable.

Page 61: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 61/70

61SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Version 8 Enhancementsdata _null_;

datetime1 = '15sep2003:08:00:00'dt ;datetime2 = datetime1;format datetime1 dtwkdatx.

datetime2 dtdate.;put datetime1= datetime2=;run ;

datetime1=Friday, 21 November 2003datetime2=21NOV03

Page 62: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 62/70

62SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Version 8 EnhancementsThe %SYSFUNC (system function)

capability was added in V6 and can beused to execute SAS Functions withinthe SAS Macro Facility

Example: Format today’s date in the TITLEUse the %SYSFUNC facility and theDATE() SAS Programming LanguageFunctionApply the WORDDATE. Format

Page 63: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 63/70

63SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Version 8 Enhancements

options nocenter ls= 80 ;proc print data=mwsug.cardtrans(obs= 10 );title1 'MWSUG 2003 Conference: Minneapolis';title2 "Report Prepared on %SYSFUNC(date(),worddate.)";title3 "Report Run Time: %SYSFUNC(time(),time.)";

run ;

Page 64: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 64/70

64SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

Version 8 EnhancementsMWSUG 2003 Conference: Minneapolis 22:53 Sunday, September 14, 2003 4Report Prepared on September 15, 2003Report Run Time: 6:50:39

trans_ card_ charge_ transaction_Obs type type cardnumber amount datetime year LOB01

1 2 12 9630-0420-1039-0391 452.34 08APR99:23:59:59 1999 O

2 1 12 9630-0420-1039-0391 955.20 24MAY99:23:59:59 1999 O3 1 12 9630-0420-1039-0391 413.37 03AUG99:23:59:59 1999 O4 1 12 9630-0420-1039-0391 795.78 12AUG99:23:59:59 1999 O5 1 12 9630-0420-1039-0391 898.87 07SEP99:23:59:59 1999 O6 1 12 9630-0420-1039-0391 361.14 11SEP99:23:59:59 1999 O7 1 12 9630-0420-1039-0391 93.42 14OCT99:23:59:59 1999 O

8 1 12 9630-0420-1039-0391 386.35 28DEC99:23:59:59 1999 O9 1 12 9630-0420-1039-0391 409.61 05JAN00:23:59:59 2000 O10 1 12 9630-0420-1039-0391 190.32 11JAN00:23:59:59 2000 O

Page 65: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 65/70

65SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

New in SAS 9.1DTRESET SAS System Option

Useful with long SAS jobs. Re-sets the dateand time information displayed in theSASLOG.

Smallest increment is minutesReset occurs when page is being written

Default is NODTRESETSASLOG displays date/time of session initialzation

ANYDATE, ANYTIME Informats

Page 66: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 66/70

66SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

New in SAS 9.1ANYDTDTEw

Reads and extract date values from “messy”raw data.DATE, DATETIME, DDMMYY, JULIAN,MMDDYY, MONYY, TIME, YYMMDD, YYQinformat values

ANYDTDTwANYDTMEw

Page 67: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 67/70

67SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

New in SAS 9.1data messy;input date anydtdte21.;date2 = date;datalines;14JAN200414JAN2004 12:24:32.8

140120042004014011420042004011404Q1;run ;

Page 68: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 68/70

68SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. Thisdocument copyright © 2004 by Sierra Information Services. All rights reserved.

New in SAS 9.1Working with SAS Date and Time Functions

The ANYDTDTE Informat, New in SAS 9.1

Obs date date2

1 16084 January 14, 2004

2 16084 January 14, 20043 16084 January 14, 20044 16084 January 14, 20045 16084 January 14, 20046 16084 January 14, 2004

7 16071 January 1, 2004

Page 69: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 69/70

69SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. This

document copyright © 2004 by Sierra Information Services. All rights reserved.

New in SAS 9.1The WEEK Function

Returns the week number from a SAS dateDefault: First Sunday of the week is WEEK 1

For dates prior to the first Sunday, the valuereturned by the WEEK Function is 0 (zero)

Optional DescriptorsChange the basis for determining the first week ofthe year

See the SAS 9.1 Documentation for the WEEKFunction

Page 70: DateAndTime.pdf

8/9/2019 DateAndTime.pdf

http://slidepdf.com/reader/full/dateandtimepdf 70/70

70SAS is a registered trademark of SAS Institute in the USA and other countries ® indicates USA registration. This

document copyright © 2004 by Sierra Information Services. All rights reserved.

Thanks for Attending !

Questions ?Comments ?Copies of this presentation:

www. SierraInformation .com