|
:o) That got me laughing at myself.
Yeah, the horizon I was envisioning
was a bit more modest. har har
For a small number its one of the cute
approaches, but as you infer, Nat+Joe's
approach is more robust.
I didn't think the small set of matches
would turn out to be the Friday Humor. har har
Mark :o) <vbg>
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Gerhard Hellriegel
Sent: Friday, May 22, 2009 10:32 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Deleting rows in a data set...help required
hmm, also with 2000 variables?
tmp = id1*1e3998+id2*1e3996+id3*1e3994+...+id2000;
!
here its necessary to get a bit exacter!
at some other locations too, eg here:
if tmp in(11111111...,22222222...) then delete;
Gerhard
On Fri, 22 May 2009 10:10:02 -0700, Terjeson, Mark
<Mterjeson@RUSSELL.COM>
wrote:
>Hi Dinesh,
>
>This can be handled many ways.
>
>Here is one fun way using pattern matching
>to reduce the number of lines of code and
>the number of pieces to process:
>
>
>data sample;
> input id1 id2 id3 id4;
>cards;
>11 12 22 11
>22 11 12 12
>11 11 11 11
>12 21 12 21
>11 22 12 12
>12 21 22 11
>11 22 22 22
>22 22 22 22
>12 21 22 11
>11 22 11 21
>;
>run;
>
> * a unique pattern handling approach ;
>data result(drop=tmp stmp i);
> set sample;
> tmp = id1*1e6+id2*1e4+id3*1e2+id4;
> if tmp in(11111111,22222222) then delete;
> stmp = put(tmp,8.);
> do i = 1 to 4;
> substr(stmp,i*2-1,2) = tranwrd(substr(stmp,i*2-1,2),'21','12');
> end;
> if stmp eq '12121212' then delete;
>run;
>
>
>
>
>Of course, the number of variables can be
>accommodated by increasing/decreasing the
>tmp= formula and adjusting the do loop
>end count.
>
>
>
>Hope this is helpful.
>
>
>Mark Terjeson
>Investment Business Intelligence
>Investment Management & Research
>Russell Investments
>253-439-2367
>
>
>Russell
>Global Leaders in Multi-Manager Investing
>
>
>
>
>
>-----Original Message-----
>From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
>Dinesh
>Sent: Friday, May 22, 2009 9:22 AM
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Deleting rows in a data set...help required
>
>Dear All,
>
>I have some problems with my analysis..
>
>I have a data set with around 2000 columns and 50000 rows....
>
>the dataset appears like this...
>
> id1 id2 id3 id4---------
>1 11 12 22 11
>2 22 11 12 12
>3 11 11 11 11
>4 12 21 12 21
>5 11 22 12 12
>6 12 21 22 11
>7 11 22 22 22
>8 22 22 22 22
>9 12 21 22 11
>10 11 22 11 21
>-
>-
>-
>-
>
>Now..what i need is that, if a particular row contain same values
>throughout the 2000 columns i want to delete it.
>So if a row contains all 11 or all 22 or all 12 or all 21 it should be
>deleted... also 12 and 21 are same and if a row contains only 12 and
>21 it can also be deleted...
>
>so the final output will appear like
>
> id1 id2 id3 id4------
>1 11 12 22 11
>2 22 11 12 12
>5 11 22 12 12
>6 12 21 22 11
>7 11 22 22 22
>9 12 21 22 11
>10 11 22 11 21
>-
>-
>-
>-
>
>rows 3 , 4 and 8 should be deleted...
>
>
>Please help me to solve this
>
>Thanks
>
>Dinu
|