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 (November 2008, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 4 Nov 2008 11:49:56 -0500
Reply-To:     SAS_learner <proccontents@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         SAS_learner <proccontents@GMAIL.COM>
Subject:      Macro to convert Dates to 8601 format.
Content-Type: text/plain; charset=ISO-8859-1

Hello _all_ ,

I wrote this Small Macro to convert the dates to ISO 8601 format and when I am calling in a datastep it is giving me error What is that I am doing wrong here . Any Ideas thanks for the help.

ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &O_date. Not In ('nd' 'un' '' 'na' ) /*Getting the Date into ISO 8601 format YYYY-MM-DDTHH-MM-SS*/;

Options Symbolgen Mprint ; %Macro Sdtm_date(O_date= , S_date = ) ; *Ora date variable*; %If &O_date. Not In ('nd' 'un' '' 'na' ) %Then %Do; /*Case-1 Year-Month-Day are present*/ %If Length(&O_date.) = 9 %Then &S_date.=Cats(Substr(&O_date.,6,4),'-',Put(Substr(&O_date.,3,3),$Monthf.),'-',Substr(&O_date.,1,2)); /*Case-2 Year-Month are present*/ %Else %If Length(&O_date.) = 7 %Then &S_date.=Cats(Substr(&O_date.,4,4),'-',Put(Substr(&O_date.,1,3),$Monthf.)); /*Case-3 Year are present*/ %Else &S_date. = &O_date.; %End ; %mend Sdtm_date;

SL


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