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 (March 1996, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 13 Mar 1996 22:37:04 -0800
Reply-To:     Andrew James Llwellyn Cary <ajlcary@IX.NETCOM.COM>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Andrew James Llwellyn Cary <ajlcary@IX.NETCOM.COM>
Organization: Cary Consulting Services
Subject:      Re: Help with Date Conversion

Michael Babyak wrote: > > Dear SAS folks, > > I was wondering if anyone could offer us some advice on the > following problem: > > We have two variables, one for time of day in hh:mm:ss > format, which was entered in clock time (ie, 1 through 12 > hours), and a second coded as AM or PM. We'd like to > recode these two variables into one military time variable. > Can anyone offer a way to do this? > > Many thanks in advance. > > Mike Babyak > > -- > Mike Babyak, PhD > Behavioral Cardiology Laboratory > Department of Psychiatry > Box 3119 > Duke University Medical Center > Durham, NC 27710 > (919) 684-8843 > (919) 684-8629 > babya001@mc.duke.edu

Just for fun. let's go with the most obfuscated code:

Assumes your hh:mm:ss data is in a SAS time values called TIME AM/PM flag is in a 2 byte character variable called AMPM

DATA new; set old; TIME = TIME + (AMPM='PM') * 12 * 60 * 60; run;

Andy -- Andrew J. L. Cary | I Reckon that the Opinions Senior Curmudgeon | expressed here DO represent Cary Consulting Services, Newark, CA | those of the management of ajlcary@ix.netcom.com | Cary Consulting Services


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