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 (September 2003, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 15 Sep 2003 10:45:49 -0400
Reply-To:     "Droogendyk, Harry" <Harry.Droogendyk@CIBC.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Droogendyk, Harry" <Harry.Droogendyk@CIBC.COM>
Subject:      Re: What's wrong with this code?
Content-Type: text/plain; charset="iso-8859-1"

Elmaache:

first.variable_name results in Boolean values, 1 = true, 0 = false, not the actual first value of variable_name in the group.

if first.montstar then firststar = montstar; if first.montend the firstend = montend;

etc.. will get you the values you're apparently looking for. However, montstar/end etc.. are MONTH values, not the dates from the original data. In addition, the last sort introduces a new variable, WEEK, which doesn't appear anywhere else in the code. It's also unclear what you're expecting where the date ranges ( weeks? ) cross month boundaries.

Perhaps something like this is what you really want ( e.g. min / max values for date/end within month ) ?

proc sql; create table aa as select year, month(date) as month, min(date) as low_date, max(date) as hi_date, min(end) as low_end, max(end) as hi_end from a group by year, calculated month ; quit; proc print; format low_date hi_date low_end hi_end date9.; run;

If not, you'll probably receive more help if you can clarify what you're expecting, e.g. what you expect your output dataset to look like.

-----Original Message----- From: Elmaache, Hamani [mailto:Hamani.Elmaache@CCRA-ADRC.GC.CA] Sent: September 15, 2003 10:01 AM To: SAS-L@LISTSERV.UGA.EDU Subject: What's wrong with this code?

Hi there.

I have a data set like these:

year date end

1994 24JAN94 30JAN94 1994 31JAN94 06FEB94 1994 07FEB94 13FEB94 1994 14FEB94 20FEB94 1994 21FEB94 27FEB94 1994 28FEB94 06MAR94 1994 07MAR94 13MAR94 1994 14MAR94 20MAR94 1994 21MAR94 27MAR94 1994 28MAR94 03APR94 1994 04APR94 10APR94 1994 11APR94 17APR94 1994 18APR94 24APR94 1994 25APR94 01MAY94 1994 02MAY94 08MAY94 1994 09MAY94 15MAY94 1995 30JAN95 05FEB95 1995 06FEB95 12FEB95 1995 13FEB95 19FEB95 1995 20FEB95 26FEB95 1995 27FEB95 05MAR95 1995 06MAR95 12MAR95 1995 13MAR95 19MAR95 1995 20MAR95 26MAR95 1995 27MAR95 02APR95 1995 03APR95 09APR95 1995 10APR95 16APR95 1995 17APR95 23APR95 ;

I want to get the first operation per month and year for the variable date and the same thing for the variable end. I wrote the following code, but it doesn't work. No error message in log.

Here my code:

data a; set a ; montstar=month(date); montend=month(end); daystar=day(date); dayend=day(end); run; proc sort data=a out=aa; by year montend montstar;

data aa; set aa; by year montend montstar; firststar=first.montstar ; firstend=first.montend ; laststar=last.montstar ; lastend=last.montend ;

proc sort data=aa ; by year week; run;

can somebady see why? Thanks a lot.


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