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 2000, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 16 Nov 2000 09:18:25 -0500
Reply-To:     Ian Whitlock <WHITLOI1@WESTAT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ian Whitlock <WHITLOI1@WESTAT.COM>
Subject:      Re: Time Indicator Variables
Comments: To: "Huang, Ya" <ya.huang@AGOURON.COM>
Content-Type: text/plain; charset="iso-8859-1"

Ya,

Again nice work.

Many people do not know the tricks of named input, since it is not well documented, and how handy it can be for tailored test data. I have rewritten your first step and illustrated with the first record on two lines how one can deal with wide files where one may want to omit extra variables for a particular test case (START was extra for first case an ROOM for the last).

data xx; informat room $1. day date7. start end time5. ; format day date. start time. end time.; input room= ; cards ; room=A / day=12NOV00 end=9:00 room=A day=12NOV00 start=11:00 end=14:20 room=B day=12NOV00 start=9:00 end=12:00 room=B day=12NOV00 start=12:30 end=16:00 room=C day=15NOV00 start=10:00 end=17:00 room=C day=16NOV00 start=8:00 end=9:00 room=C day=16NOV00 start=9:30 end=11:00 room=A day=20NOV00 start=8:00 end=9:00 room=A day=20NOV00 start=11:00 end=14:20 room=B day=20NOV00 start=9:00 end=12:00 room=B day=20NOV00 start=12:30 end=16:00 room=C day=20NOV00 start=10:00 end=17:00 room=C day=20NOV00 start=8:00 end=9:00 room=C day=20NOV00 start=9:30 end=11:00 run;

You can avoid the unitialized messages by finishing the INPUT statement to please the compiler, but, in fact, any variable is the PDV is searched for and they can occur in any order.

Ian Whitlock <whitloi1@westat.com>

-----Original Message----- From: Huang, Ya [mailto:ya.huang@AGOURON.COM] Sent: Wednesday, November 15, 2000 4:11 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Time Indicator Variables

Daniel, I hope the following code can give you some hint. data xx; room='A'; day='12NOV00'd; start='8:00't; end='9:00't; output; room='A'; day='12NOV00'd; start='11:00't; end='14:20't; output; room='B'; day='12NOV00'd; start='9:00't; end='12:00't; output; room='B'; day='12NOV00'd; start='12:30't; end='16:00't; output; room='C'; day='15NOV00'd; start='10:00't; end='17:00't; output; room='C'; day='16NOV00'd; start='8:00't; end='9:00't; output; room='C'; day='16NOV00'd; start='9:30't; end='11:00't; output; room='A'; day='20NOV00'd; start='8:00't; end='9:00't; output; room='A'; day='20NOV00'd; start='11:00't; end='14:20't; output; room='B'; day='20NOV00'd; start='9:00't; end='12:00't; output; room='B'; day='20NOV00'd; start='12:30't; end='16:00't; output; room='C'; day='20NOV00'd; start='10:00't; end='17:00't; output; room='C'; day='20NOV00'd; start='8:00't; end='9:00't; output; room='C'; day='20NOV00'd; start='9:30't; end='11:00't; output; format day date. start time. end time.; run; * expand the data with a 10 minutes increment; data xx; set xx; dummy=1; do time=start to end-'00:10't by '00:10't; output; end; format time time.; options nocenter; ** count the number of time segments, then times 10 min to; ** get the total time, same way to count total time in; ** specific time frame (11:30-12:30); proc sql; create table xx as select distinct room, day, sum(dummy)*'00:10't as day_sum format=time., sum(dummy*('11:30't<=time<'12:30't))*'00:10't as noon_sum format=time. from xx group by room, day ; proc print; run; ------------------------ The SAS System 11:47 Wednesday, November 15, 2000 2968 Obs room day day_sum noon_sum 1 A 12NOV00 4:20:00 1:00:00 2 A 20NOV00 4:20:00 1:00:00 3 B 12NOV00 6:30:00 0:30:00 4 B 20NOV00 6:30:00 0:30:00 5 C 15NOV00 7:00:00 1:00:00 6 C 16NOV00 2:30:00 0:00:00 7 C 20NOV00 9:30:00 1:00:00 It won't be difficult to get futher information from the above data set, such as average hours in noon ( use sql or proc means etc.) Regards, Ya Huang


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