Published on :
Statistical CREATION_INTERNE

Multiple Imputation with PROC MI on Fish Data

This code is also available in: Deutsch Español Français
Awaiting validation
The script begins by creating a 'Fish1' dataset containing fish length measurements, where some values have been intentionally set to missing to create a monotonic pattern. Then, the PROC MI procedure is used to perform multiple imputation (8 imputations are generated). It uses standard regression for the 'Length2' variable and a predictive mean matching (PMM) method for 'Length3'. The results are stored in the 'outex3' table. Finally, the first 10 rows of the imputed dataset are displayed for verification.
Data Analysis

Type : CREATION_INTERNE


The 'Fish1' dataset is created directly within the script using a DATA STEP statement and DATALINES.

1 Code Block
DATA STEP Data
Explanation :
This code block creates the 'Fish1' table. It reads three numeric variables (Length1, Length2, Length3) from data embedded directly via 'datalines'. Some observations have missing values (represented by '.') to simulate an incomplete dataset with a monotonic pattern.
Copied!
1DATA Fish1;
2 title 'Fish Measurement Data';
3 INPUT Length1 Length2 Length3 @code_sas_json/8_SAS_Intro_ReadFile_MultiCol_@@.json;
4 DATALINES;
523.2 25.4 30.0 24.0 26.3 31.2 23.9 26.5 31.1
626.3 29.0 33.5 26.5 29.0 . 26.8 29.7 34.7
726.8 . . 27.6 30.0 35.0 27.6 30.0 35.1
828.5 30.7 36.2 28.4 31.0 36.2 28.7 . .
929.1 31.5 . 29.5 32.0 37.3 29.4 32.0 37.2
1029.4 32.0 37.2 30.4 33.0 38.3 30.4 33.0 38.5
1130.9 33.5 38.6 31.0 33.5 38.7 31.3 34.0 39.5
1231.4 34.0 39.2 31.5 34.5 . 31.8 35.0 40.6
1331.9 35.0 40.5 31.8 35.0 40.9 32.0 35.0 40.6
1432.7 36.0 41.5 32.8 36.0 41.6 33.5 37.0 42.6
1535.0 38.5 44.1 35.0 38.5 44.0 36.2 39.5 45.3
1637.4 41.0 45.9 38.0 41.0 46.5
17;
18 
2 Code Block
PROC MI Data
Explanation :
This procedure performs multiple imputation on the 'Fish1' table. 'nimpute=8' requests the creation of 8 imputed datasets. The 'monotone' method is specified, with regression ('reg') for 'Length2' and predictive mean matching regression ('regpmm') for 'Length3'. The 'seed' is fixed for reproducibility. The result is saved in the 'outex3' table.
Copied!
1PROC MI DATA=Fish1 round=.1 mu0= 0 35 45
2 seed=13951639 nimpute=8 out=outex3;
3 monotone reg(Length2/ details)
4 regpmm(Length3= Length1 Length2 Length1*Length2/ details);
5 var Length1 Length2 Length3;
6RUN;
3 Code Block
PROC PRINT
Explanation :
This block displays the first 10 observations of the 'outex3' dataset, which contains the values imputed by PROC MI, allowing for quick verification of the result.
Copied!
1 
2PROC PRINT
3DATA=outex3(obs=10);
4title 'First 10 Observations of the Imputed
5Data Set';
6RUN;
7 
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 : S A S S A M P L E L I B R A R Y