| Date: | Tue, 6 May 2008 12:09:02 -0400 |
| Reply-To: | TIFFANY SWINIMER <SWINIMTI@MPAC.CA> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | TIFFANY SWINIMER <SWINIMTI@MPAC.CA> |
| Subject: | Re: Looping into a data step |
|
| In-Reply-To: | <932afa36-3cfc-4b88-8ea2-8149288f401b@m44g2000hsc.googlegroups.com> |
| Content-Type: | text/plain; charset=US-ASCII |
Hi Christophe,
I would try some enumeration, then a sum of that enumeration...
data test;
input A B C ;
cards;
1 197 31
1 197 10
2 197 31
2 195 10
2 199 26
3 197 31
;
run;
data test;
set test;
count +1;
by A;
if first.a then count = 1;
run;
*/this will produce the following*/
1 197 31 1
1 197 10 2
2 197 31 1
2 195 10 2
2 199 26 3
3 197 31 1
Then, a proc means would sum the count variable
proc means data = test noprint;
class A;
var count;
output out = testsum
sum = count_sum;
run;
then, merge the counted variable back into the data set;
data test2;
merge test testsum;
by A;
run;
gives the following....
1 197 31 1 2
1 197 10 2 2
2 197 31 1 3
2 195 10 2 3
2 199 26 3 3
3 197 31 1 1
Then, an if statement
data final;
set test2;
if B = 197 and C = 31 and count_sum ne 1 then delete;
run;
I'm sure there could be a faster more efficient way to do this... but that's my two cents
Tiffany
>>> cparatte <christophe@PARATTE.NET> 5/6/2008 10:52 AM >>>
Hi all
I am wondering how to get the lines X 197 31 out of a table using a
data step :
data test;
input A B C ;
cards;
1 197 31
1 197 10
2 197 31
2 195 10
2 199 26
3 197 31
;
run;
For instance, with this table I want the line 3 197 31 because no more
other article than 197 and 31 are listed.
Any clue ?
Thanks in advance
Christophe Paratte
|