BookmarkSubscribeRSS Feed
whyamihere
Calcite | Level 5

I need to impute the median value for each cluster back into the data set. The clustering gives me this:

whyamihere_0-1745014646500.png

Then I edited the code and added the following code but obviously got errors. Where should I go from here? What step am I missing?  Thanks so much

proc hpimpute data=_chardata_sorted out=supportimputed;
    by cluster;
    input charges=.;
    impute charges / method=pmedian;
run;
1 REPLY 1
Ksharp
Super User
I don't understand what you are trying to do.
You want to impute missing value with median or just bring median into original dataset ?

1) if you want to impute missing value with median, try this:
proc stdize data=have missing=median reponly;
by cluster;
run;

2)if you want to bring median value back into orginal dataset, try this:

proc summary data=have;
by cluster;
var var;
output out=median median=median_var;
run;
data want;
merge have median;
by cluster;
run;

3)Last, if you just simply impute missing WITHOUT median ,try PROC MI.
https://blogs.sas.com/content/iml/2020/12/02/score-external-logistic-model.html