LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (November 2011, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 25 Nov 2011 17:25:10 +0000
Reply-To:   "Zdeb, Michael S" <mzdeb@ALBANY.EDU>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Zdeb, Michael S" <mzdeb@ALBANY.EDU>
Subject:   Re: Converting unformatted character variable values to SAS time values XXXX
Comments:   To: Dan Abner <dan.abner99@GMAIL.COM>
In-Reply-To:   <CAPRGo-mAGCXU3uMraGgcuBSyBXo9WcuJGk7yK8+M=fRNV-56qw@mail.gmail.com>
Content-Type:   text/plain; charset="iso-8859-1"

hi ... from version 9.3 ...

if it's already a character variable, just reread the value with a time-related informat ...

data x; input tm : $4. @@; datalines; 317 317 336 336 336 1550 1550 1550 1544 1544 1547 1547 1547 ; run;

data y; set x; tod = input(tm,hhmmss.); format tod time5.; run;

if not version 9.3 (assumes the length of the character variable with the time of day is 4)...

data y; set x; tod = input(catx(':',substr(right(tm),1,2),substr(right(tm),3)),time5.); format tod time5.; run;

Mike Zdeb U@Albany School of Public Health One University Place (Room 119) Rensselaer, New York 12144-3456 P/518-402-6479 F/630-604-1475

________________________________________ From: SAS(r) Discussion [SAS-L@LISTSERV.UGA.EDU] on behalf of Dan Abner [dan.abner99@GMAIL.COM] Sent: Friday, November 25, 2011 9:49 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Converting unformatted character variable values to SAS time values XXXX

Hello everyone,

I have a character variable of unformatted 24 hour times (see below). What is the easiest way to convert these to a proper numeric SAS time variable?

317 317 336 336 336 1550 1550 1550 1544 1544 1547 1547 1547

Thanks!

Dan


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