From: my0402 on
>From an old thread, circa 2005:

toby dunn <tobyd...(a)hotmail.com> wrote:
> I am trying to create deciles but I need the obs weighted by another
> variable. Does Proc Rank have a wieght statement like proc freq does
or is
> there a better way to get to where I want to go here.

PROC UNIVARIATE has a WEIGHT statement, and will compute weighted
quantiles for you. Try that. You'll have to specify your deciles,
but the proc will allow that. Like this:

proc univariate data=meshugineh noprint;
var whatever;
weight ohsure;
output out=YourTrafe
pctlpts=10 to 90 by 10
pctlpre=Dec_ ;
run;

Of course, if the data come from a survey sample with weights - and
possibly other design features - then these point estimates will be
okay but the standard errors and variances from PROC UNIVARIATE will
all be wrong. _caveat_utor_ .

HTH,
David
--
David Cassell, CSC
Cassell.Da...(a)epa.gov
Senior computing specialist
mathematical statistician

================================

If a record's predicted value is in the top 10%, the record falls into
a segment_a, else it doesn't. There's also a 2nd algorithm predicting
a different segment_b with the same data, also being assigned by the
top 10% of that predicted value. A record can't be in 2 segments, so
if it does fall into both, it gets assigned to segment_a.

The data are weighted. I don't think I'm handling the weighted aspect
correctly.

data prob;
set data_adjust;
pred =
( AGE * -.12345 )+
( EDUC * .67891 )+
( HHINC * .000246801 )+
( RACEO * -.098765 )+
etc. +
-.0010203
;
run;

proc univariate data=prob;
var pred;
weight pop_wt;
output
out = pred
P90 = pred_90
;
run;

proc sql;
select
pred_90
into
:p90
from pred
;
quit;

data prob;
set prob;
if pred ge &p90 then SEGMENT = 1;
else SEGMENT = 0;
run;

proc rank data=prob out=prob_rank descending;
var pred;
ranks pred_RANK;
run;

Is this correct?

Thanks.
Myra

From: BruceBrad on
On Feb 21, 2:58 am, my0...(a)gmail.com wrote:
> >From an old thread, circa 2005:
> toby dunn <tobyd...(a)hotmail.com> wrote:
> > I am trying to create deciles but I need the obs weighted by another
> > variable. Does Proc Rank have a wieght statement like proc freq does
> or is
> > there a better way to get to where I want to go here.
>
> PROC UNIVARIATE has a WEIGHT statement, and will compute weighted
> quantiles for you. Try that. You'll have to specify your deciles,
> but the proc will allow that. Like this:
>
> proc univariate data=meshugineh noprint;
> var whatever;
> weight ohsure;
> output out=YourTrafe
> pctlpts=10 to 90 by 10
> pctlpre=Dec_ ;
> run;
>
> Of course, if the data come from a survey sample with weights - and
> possibly other design features - then these point estimates will be
> okay but the standard errors and variances from PROC UNIVARIATE will
> all be wrong. _caveat_utor_ .
>
> HTH,
> David
> --
> David Cassell, CSC
> Cassell.Da...(a)epa.gov
> Senior computing specialist
> mathematical statistician
>
> ================================
>
> If a record's predicted value is in the top 10%, the record falls into
> a segment_a, else it doesn't. There's also a 2nd algorithm predicting
> a different segment_b with the same data, also being assigned by the
> top 10% of that predicted value. A record can't be in 2 segments, so
> if it does fall into both, it gets assigned to segment_a.
>
> The data are weighted. I don't think I'm handling the weighted aspect
> correctly.
>
> data prob;
> set data_adjust;
> pred =
> ( AGE * -.12345 )+
> ( EDUC * .67891 )+
> ( HHINC * .000246801 )+
> ( RACEO * -.098765 )+
> etc. +
> -.0010203
> ;
> run;
>
> proc univariate data=prob;
> var pred;
> weight pop_wt;
> output
> out = pred
> P90 = pred_90
> ;
> run;
>
> proc sql;
> select
> pred_90
> into
> :p90
> from pred
> ;
> quit;
>
> data prob;
> set prob;
> if pred ge &p90 then SEGMENT = 1;
> else SEGMENT = 0;
> run;
>
> proc rank data=prob out=prob_rank descending;
> var pred;
> ranks pred_RANK;
> run;
>
> Is this correct?
>
> Thanks.
> Myra


From: BruceBrad on
This makes sense up to the proc rank statement. Why are you including
this? Haven't you solved your problem in the previous data step?

From: my0402 on
On Feb 20, 11:16 pm, "BruceBrad" <BruceB...(a)iname.com> wrote:
> This makes sense up to the proc rank statement. Why are you including
> this? Haven't you solved your problem in the previous data step?

Though segment_a is the dominant if the predicted value falls in both,
another solution is taking the segment in which the weighted record
has the higher rank. That's why I want to look at weighted ranks.
Sorry I didn't make that clearer to begin with.

Myra


From: my0402 on
On Feb 20, 10:58 am, my0...(a)gmail.com wrote:
> >From an old thread, circa 2005:
> toby dunn <tobyd...(a)hotmail.com> wrote:
> > I am trying to create deciles but I need the obs weighted by another
> > variable. Does Proc Rank have a wieght statement like proc freq does
> or is
> > there a better way to get to where I want to go here.
>
> PROC UNIVARIATE has a WEIGHT statement, and will compute weighted
> quantiles for you. Try that. You'll have to specify your deciles,
> but the proc will allow that. Like this:
>
> proc univariate data=meshugineh noprint;
> var whatever;
> weight ohsure;
> output out=YourTrafe
> pctlpts=10 to 90 by 10
> pctlpre=Dec_ ;
> run;
>
> Of course, if the data come from a survey sample with weights - and
> possibly other design features - then these point estimates will be
> okay but the standard errors and variances from PROC UNIVARIATE will
> all be wrong. _caveat_utor_ .
>
> HTH,
> David
> --
> David Cassell, CSC
> Cassell.Da...(a)epa.gov
> Senior computing specialist
> mathematical statistician
>
> ================================
>
> If a record's predicted value is in the top 10%, the record falls into
> a segment_a, else it doesn't. There's also a 2nd algorithm predicting
> a different segment_b with the same data, also being assigned by the
> top 10% of that predicted value. A record can't be in 2 segments, so
> if it does fall into both, it gets assigned to segment_a.
>
> The data are weighted. I don't think I'm handling the weighted aspect
> correctly.
>
> data prob;
> set data_adjust;
> pred =
> ( AGE * -.12345 )+
> ( EDUC * .67891 )+
> ( HHINC * .000246801 )+
> ( RACEO * -.098765 )+
> etc. +
> -.0010203
> ;
> run;
>
> proc univariate data=prob;
> var pred;
> weight pop_wt;
> output
> out = pred
> P90 = pred_90
> ;
> run;
>
> proc sql;
> select
> pred_90
> into
> :p90
> from pred
> ;
> quit;
>
> data prob;
> set prob;
> if pred ge &p90 then SEGMENT = 1;
> else SEGMENT = 0;
> run;
>
> proc rank data=prob out=prob_rank descending;
> var pred;
> ranks pred_RANK;
> run;
>
> Is this correct?
>
> Thanks.
> Myra