Published on :
Statistical CREATION_INTERNE

Multiple Imputation Example with PROC MI

This code is also available in: Deutsch Español Français
Awaiting validation
The script begins by creating a 'Fitness1' dataset containing physical fitness measurements (oxygen consumption, run time, pulse). Some of these measurements are missing. Then, the MI procedure is used to impute these missing values by generating 40 complete datasets. Imputation is based on a Markov Chain Monte Carlo (MCMC) method, with a specified seed to ensure reproducibility.
Data Analysis

Type : CREATION_INTERNE


The data is created directly within the script via a DATA step and the DATALINES statement. No external data source is required.

1 Code Block
DATA STEP Data
Explanation :
This block creates the 'Fitness1' table from data embedded in the code (datalines). The 'input' statement reads the Oxygen, RunTime, and RunPulse variables. The ' @@' specifier allows reading multiple observations from the same data line.
Copied!
1DATA Fitness1;
2 INPUT Oxygen RunTime RunPulse @code_sas_json/8_SAS_Intro_ReadFile_MultiCol_@@.json;
3 DATALINES;
444.609 11.37 178 45.313 10.07 185
554.297 8.65 156 59.571 . .
649.874 9.22 . 44.811 11.63 176
7 . 11.95 176 . 10.85 .
839.442 13.08 174 60.055 8.63 170
950.541 . . 37.388 14.03 186
1044.754 11.12 176 47.273 . .
1151.855 10.33 166 49.156 8.95 180
1240.836 10.95 168 46.672 10.00 .
1346.774 10.25 . 50.388 10.08 168
1439.407 12.63 174 46.080 11.17 156
1545.441 9.63 164 . 8.92 .
1645.118 11.08 . 39.203 12.88 168
1745.790 10.47 186 50.545 9.93 148
1848.673 9.40 186 47.920 11.50 170
1947.467 10.50 170
20;
21 
2 Code Block
PROC MI
Explanation :
This block uses the Multiple Imputation (MI) procedure on the 'Fitness1' table. It is configured to generate 40 imputed datasets ('nimpute=40') using an MCMC method. The 'seed' option ensures reproducibility. The variables to be imputed are specified in the 'var' statement.
Copied!
1PROC MI DATA=Fitness1 seed=21355417 nimpute=40 mu0=50 10 180;
2 mcmc chain=multiple displayinit initial=em(itprint);
3 var Oxygen RunTime RunPulse;
4RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : SAS SAMPLE LIBRARY. NAME: MIEX9. TITLE: Documentation Example 9 for PROC MI. PRODUCT: STAT. REF: PROC MI, EXAMPLE 9