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 (May 2001, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 24 May 2001 17:15:56 -0700
Reply-To:     Dale McLerran <dmclerra@MY-DEJA.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Dale McLerran <dmclerra@MY-DEJA.COM>
Subject:      Re: I wish I had paid attention in Fortran class...
Comments: To: todd@psychiatry.uchc.edu
Content-Type: text/plain

Todd,

The solution for your problem is simpler than a do loop. All that you need is to check the condition INT. If INT=0 then you start a new day. To do that, you just need the following code

day + (int=0);

That's all there is to it. The variable day gets incremented whenever the condition (int=0) is true, or whenever INT=0. Also, when we use the above construction "day + ..." without specifying an equals sign, the variable day is retained from one record to the next.

Dale

>Date: Thu, 24 May 2001 18:35:02 -0400 >Reply-To: "Todd, Mike" <todd@PSYCHIATRY.UCHC.EDU> >From: "Todd, Mike" <todd@PSYCHIATRY.UCHC.EDU> >SUBJECTTo: SAS-L@LISTSERV.UGA.EDU > >Hi all: > >I have a basic programming question that I'm hoping someone can help me >with. > >I have a rather large data set that I need to add a variable to. The data >file has a variable called INT that has values corresponding to different >times of day. Each day begins when INT = 0. What I would like to to is >create a "DAY" variable that assigns a value of 1 to INT for all of the >1st-day observations, a value of 2 for all of the 2nd-day observations, and >so on to the end of the file. > >The first 3 columns (TIME, SI, INT) in the text below my signature are data >from the data set, while DAY is the variable I would like to create. > >I have the feeling there is some simple do loop solution that I just can't >think of. Any help would be appreciated. Thanks! > >-mike > >Michael Todd, Ph.D. >University of Connecticut Health Center >Alcohol Research Center-MC2103 >Department of Psychiatry >263 Farmington Avenue >Farmington CT 06030-2103 > >Voice: 860.679.5468 >Fax: 860.679.5464 >E-mail: todd@psychiatry.uchc.edu > > > TIME SI INT DAY > 5:45:00 23.00 .00 1 >10:11:00 24.00 1.00 1 >16:07:00 25.00 2.00 1 >16:13:00 25.00 2.00 1 >18:02:00 26.00 3.00 1 >19:58:00 27.00 3.00 1 >20:38:00 28.00 3.00 1 > 5:46:00 29.00 .00 2 >10:41:00 1.00 1.00 2 >16:02:00 2.00 2.00 2 >16:03:00 .00 3.00 2 >16:03:00 2.00 3.00 2 >18:07:00 1.00 4.00 2 >20:14:00 . 4.00 2 >20:56:00 . 4.00 2 >21:06:00 . 4.00 2 >21:45:00 8.00 4.00 2 >22:36:00 9.00 4.00 2 >23:09:00 10.00 4.00 2 > 6:46:00 11.00 .00 3 >11:49:00 12.00 1.00 3 >15:16:00 13.00 2.00 3

--------------------------------------- Dale McLerran Fred Hutchinson Cancer Research Center mailto: dmclerra@fhcrc.org Ph: (206) 667-2926 Fax: (206) 667-5977 ---------------------------------------

------------------------------------------------------------ --== Sent via Deja.com ==-- http://www.deja.com/


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