|
In the data step, "<>" means "max", not "is not equals". Use "ne"
instead.
It's a good idea to avoid the <> operator.
--
JackHamilton@FirstHealth.com
Manager, Technical Development
METRICS Department, First Health
West Sacramento, California USA
>>> "Mike Fay" <rmf4@CDC.GOV> 07/23/2002 10:52 AM >>>
Hi folks,
I can't get a DATA STEP to work. The problem must be academic. Here's
my
code:
data
hazdat.J_Assess3;
format dLast_cf_CnE 4. dRec4Pctl 4. dPctg 8.4 dPctl 8.4 cf_CnE
4.;
retain dLast_cf_CnE 0 dRec4Pctl
0;
set HazDat.J_Assess2
nobs=TotRex;
if dLast_cf_CnE <> cf_CnE then
dRec4Pctl=_n_;
dPctl = 100-(100*(dRec4Pctl-
1)/TotRex);
dLast_cf_CnE=cf_CnE;
run;
***
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
the data.
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.
dLast_cf_CnE=cf_CnE;
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?
Thanks,
Mike, Atlanta
|