Date: Wed, 23 Mar 2005 20:44:24 GMT
Reply-To: LWn <Lars.WahlgrenRemove@THIS.STAT.LU.SE>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: LWn <Lars.WahlgrenRemove@THIS.STAT.LU.SE>
Organization: Telia Internet
Subject: SV: Easy way to get a count of how many times a value shows up?
Alex Pavluck <firstname.lastname@example.org> skrev i
> Ok. I am having a problem that is causing me to do a lot of coding and
> I thought that the group might find this interesting. If you don't
> know how to do it IN SAS then don't send me a suggestion. Thanks.
> I have a case/control dataset that I am using to do conditional
> logistic regression modeling. The dataset contains a variable denoting
> the matched pair (matched_pairs) and will have a value twice in the
> dataset for each pair. For example:
> OBS CASE CONTROL MATCHED_PAIRS ETC
> 1 0 1 1 ...
> 2 1 0 1 ...
> 3 0 1 2 ...
> 4 1 0 2 ...
> Now, I have removed unmatched pairs but the process is very cumbersome.
> Can some suggest a way that I can get a count of MATCHED_PAIRS and
> remove those observations where the count of MATCHED_PAIRS is <2
> (indicating that the pair is missing).
Something like this perhaps
data new ;
set old ;
by matched_pairs ;
if first.matched.pairs and last.matched_pairs then delete ;
count + first.matched_pairs ;
hth / LWn