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 (June 2005, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 24 Jun 2005 08:11:29 -0700
Reply-To:   "Terjeson, Mark (IM&R)" <Mterjeson@RUSSELL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Terjeson, Mark (IM&R)" <Mterjeson@RUSSELL.COM>
Subject:   Re: How to trim 1st and last data in a series?
Comments:   To: tantrik <prabdai@HOTMAIL.COM>
Content-Type:   text/plain; charset="US-ASCII"

Hi Prab,

FIRST. and LAST. processing in the datastep is very handy. It requires that you have the dataset sorted and the in your datastep you add the BY statement to the SET statement. The BY with the SET automatically creates all the combinations of first. and last. flags for each element in the BY statement. Very Handy! Add a put _all_; to the datastep to get a visual of all these flags created. By the way, these flags get set with 0 or 1 for false or true.

data sample; input COMP STAND PLOT $ TRANS DIA; cards; 23 10 1A 1 0 23 10 1A 2 9 23 10 1A 3 0 23 10 1A 4 0 23 10 1A 5 8.5 23 10 1A 6 0 23 10 1A 7 9 23 10 1A 8 0 23 10 1A 9 0 23 10 1A 10 0 23 10 1A 11 0 23 10 1A 12 0 23 10 2A 1 28.5 23 10 2A 2 0 23 10 2A 3 0 23 10 2A 4 0 23 10 2A 5 0 23 10 2A 6 0 23 10 2A 7 0 23 10 2A 8 13 23 10 2A 8 24.5 23 10 3A 1 0 ; run;

proc sort data=sample; by COMP STAND PLOT TRANS; run;

data result; set sample; by COMP STAND PLOT TRANS; if first.plot or last.plot then delete; run;

Hope this is helpful.

Mark Terjeson Senior Programmer Analyst, IM&R Russell Investment Group

Russell Global Leaders in Multi-Manager Investing

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of tantrik Sent: Friday, June 24, 2005 7:47 AM To: SAS-L@LISTSERV.UGA.EDU Subject: How to trim 1st and last data in a series?

HI I have been too addicted to point and click but realized life's not that easy. I have a dataset like this:

COMP STAND PLOT TRANS DIA 23 10 1A 1 0 23 10 1A 2 9 23 10 1A 3 0 23 10 1A 4 0 23 10 1A 5 8.5 23 10 1A 6 0 23 10 1A 7 9 23 10 1A 8 0 23 10 1A 9 0 23 10 1A 10 0 23 10 1A 11 0 23 10 1A 12 0 23 10 2A 1 28.5 23 10 2A 2 0 23 10 2A 3 0 23 10 2A 4 0 23 10 2A 5 0 23 10 2A 6 0 23 10 2A 7 0 23 10 2A 8 13 23 10 2A 8 24.5 23 10 3A 1 0 so on................................

I want to get rid of the first and the last TRANS in a PLOT because it is outside the plot boundary. so for Plot 1A, Trans 1 and trans 12 would be out, for Plot 2A, TRANS 1 and both of the Trans 8 would be out.. How would I do it? As I mentioned, I hardly know how to spell programming. Nevertheless, i'm a quick learner and dont mind working loooong hours to learn including nights and weekends. I appreciate your valuable suggestions. HAVE A GREAT WEEKEND.

Prab Dahal Program Technician University of Arkansas-Monticello


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