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

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 379 views
  • 0 likes
  • 2 in conversation