LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2000, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 30 Oct 2000 17:29:36 +0000
Reply-To:   Peter Crawford <Peter@CRAWFORDSOFTWARE.DEMON.CO.UK>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Peter Crawford <Peter@CRAWFORDSOFTWARE.DEMON.CO.UK>
Organization:   Crawford Software Consultancy Limited
Subject:   Re: Dateformat dtdate9
Content-Type:   text/plain;charset=iso-8859-1

Magnusson, Tomas <Tomas.Magnusson@MEISTERVERLAG.DE> writes > > Dear Saslers, > > I'm using SAS v8 where we using SYBASE as Database. > It seems to be a problem using the format dtdate9 as I'm trying to > extract the year from the variable active_dte... > > (See following Error message) > > Hope for help > > Tomas Magnusson > > 110 proc sql ; > 111 create table tmp.calmdat as > 112 select cust_no format 9., > 113 activ_dte format dtdate9. > 114 > 115 from sybase.cust_action > 116 ; > > > 117 quit; > > NOTE: Table TMP.CALMDAT created, with 100 rows and 2 columns. > > 118 > 119 data sasset; > 120 set tmp.calmdat ; > 121 yeardate = year(activ_dte); > 122 run; > > NOTE: Invalid argument to function YEAR at line 121 column 15. > cust_no=111111111 activ_dte=01SEP1999 yeardate=. _ERROR_=1 _N_=1

The year() function expects a number of days since 1960 (a date variable), but the variable you provided (activ_dte) provides seconds since 1960 ( a datetime variable). There may be a function to extract year from a datetime variable ( perhaps it is dtyear() ) alternatively you can use the year() function after extracting the datepart ..... year = year( datepart( activ_dte ) ) ;

testing on v8.1

26 data demo1; 27 activ_dte = datetime(); 28 format activ_dte dtdate9. ; 29 PUT ACTIV_DTE = ; NOTE: SCL source line. 30 year1 = dtyear( activ_dte ); ------ 68 ERROR 68-185: The function DTYEAR is unknown, or cannot be accessed.

31 year2 = year( datepart( activ_dte )); 32 year3 = year( activ_dte/24/60/60 ); 33 put (year1-year3)(=); 34 run;

NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.DEMO1 may be incomplete. When this step was stopped there were 0 observations and 4 variables. WARNING: Data set WORK.DEMO1 was not replaced because this step was stopped. NOTE: DATA statement used: real time 0.05 seconds

35 data demo1; 36 activ_dte = datetime(); 37 format activ_dte dtdate9. ; 38 PUT ACTIV_DTE = ; 39 year2 = year( datepart( activ_dte )); 40 year3 = year( activ_dte/24/60/60 ); /* another way to date */ 41 put (year2-year3)(=); 42 run;

activ_dte=30OCT2000 year2=2000 year3=2000 NOTE: The data set WORK.DEMO1 has 1 observations and 3 variables. NOTE: DATA statement used: real time 0.00 seconds

-- Peter Crawford


Back to: Top of message | Previous page | Main SAS-L page