Date: Tue, 20 Aug 2002 11:56:54 -0500
Reply-To: Kevin Myers <KevinMyers@AUSTIN.RR.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Kevin Myers <KevinMyers@AUSTIN.RR.COM>
Subject: Re: inefficient code
Content-Type: multipart/alternative;
I don't believe that this will work due to the ASCII collating sequence where all lower case characters come after all uppercase characters.
----- Original Message -----
From: Greg Woolridge
Newsgroups: bit.listserv.sas-l
To: SAS-L@LISTSERV.UGA.EDU
Sent: Tuesday, August 20, 2002 11:48 AM
Subject: Re: inefficient code
I think this untested code should work
PROC SORT DATA=ALLCOMBINED;
BY GENNAM;
RUN;
DATA ALLCOMBINED;
SET ALL COMBINED;
IF UPCASE(GENNAM)=UPCASE(LAG(GENNAM)) THEN DELETE;
RUN;
Greg M. Woolridge
Manager, Study Programming
TAP Pharmaceutical Products Inc.
e-mail: greg.woolridge@tap.com
phone: 847-582-2332
fax: 847-582-2403
Kevin Auslander <kauslander@terrecrs.com>
Sent by: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
08/20/02 11:10 AM
Please respond to Kevin Auslander
To: SAS-L@LISTSERV.UGA.EDU
cc:
Subject: inefficient code
I have a dataset named AllCombined with one character variable named gennam. I want to delete all values of gennam such that upcase(gennam) = upcase(gennamprevious). where gennamprevious is any previous value of gennam. I have written code to accomplish this but I feel that it is inefficient because it uses more than two data steps. The way I see it, there should be one step for sorting and then one step for deleting the unwanted data. Here is my code which does work:
data AllCombined;
set AllCombined;
upcaseCol = upcase(gennam);
run;
proc sort data=AllCombined;
by upcaseCol;
run;
data AllCombined;
set AllCombined;
if upcaseCol = lag(upcaseCol) then delete;
run;
data AllCombined;
set AllCombined(drop = upcaseCol);
run;
Can someone please help me shorten this. TIA.
[text/html]