Date: Tue, 23 Jul 2002 13:52:56 -0400
Reply-To: Mike Fay <rmf4@CDC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mike Fay <rmf4@CDC.GOV>
Subject: Newbie DATA step sequencng question
I can't get a DATA STEP to work. The problem must be academic. Here's my
format dLast_cf_CnE 4. dRec4Pctl 4. dPctg 8.4 dPctl 8.4 cf_CnE
retain dLast_cf_CnE 0 dRec4Pctl
if dLast_cf_CnE <> cf_CnE then
dPctl = 100-(100*(dRec4Pctl-
The point is to not update dRec4Pctl unless cf_CnE is equal to its value in
the previous record (retained in dLast_cf_CnE). The reason for doing this
is because I am assigning percentiles and, if the operant variable for the
percentile (cf_CnE) is the same as the previous record, then the percentile
value should be the same as for when that value of cf_CnE was first seen in
An analogy, if that's not clear, is that if we sort on a field and then
rank the records 1, 2, 3, etc. based on the value of that field, and if we
then have two records 'tied' for third place because their field value is
the same, the 3rd and 4th record would get rank 3, and then the 5th record
would get rank 5.
Anyway, somehow dRec4Pctl is always equal to _n_ in each of the output
records, and I don't get any recognition when cf_CnE repeats its values. In
other words, the Percentile (dPctl) is always equal to (_n_-1)/TotRex, even
though the IF statement should not be updating dRec4Pctl all the time.
should only be happening after the other tests and code have run, but I
suspect I am being bitten by the SAS execution timing daemon, and it's
happening before the IF test somehow, which would cause what I see.
Is this clear as mud? :) Help please?