Last active
October 25, 2017 15:16
-
-
Save statgeek/cbd6bd253b4ab4828dd71d0ce3d17199 to your computer and use it in GitHub Desktop.
SAS - Replace missing values with Mean
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*Create sample with missing data; | |
data missing; | |
set sashelp.class; | |
if mod(_n_, 2) eq 1 then | |
call missing(of _numeric_); | |
run; | |
*Display for example purposes; | |
title 'Original data'; | |
proc print ; | |
run; | |
*Show mean values to check results; | |
title 'Mean results to check output' proc means data=missing mean; | |
run; | |
*Replace missing with mean, for ALL NUMERIC variables. If you want specific variables | |
add them via a VAR statement; | |
proc stdize out=class_mean reponly method=mean; | |
run; | |
*Diplay results for example; | |
title 'Final - Missing replaced with Mean'; | |
proc print data=class_mean; | |
run; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment