Example 17 for PROC MI: Multiple Imputation with MNAR adjustment

This code is also available in: Deutsch Español Français
Difficulty Level
Beginner
Published on :
This script first creates a synthetic dataset named 'Mono2' with conditionally simulated missing values. It then uses the MI (Multiple Imputation) procedure to impute the missing data. The peculiarity of this example lies in the use of the MNAR (Missing Not At Random) statement combined with a monotonic logistic method (link=glogit) for the 'Grade' variable, applying a specific shift to the imputed values.
Data Analysis

Type : CREATION_INTERNE


The data is entirely generated within the script via a Data Step using DO loops and random number generators (ranuni, rannor).

1 Code Block
DATA STEP Data
Explanation :
Generation of the 'Mono2' dataset containing demographic and score variables, with artificial introduction of missing values for the 'Grade' variable based on defined probabilities.
Copied!
1DATA Mono2;
2 DO Grd= 6 to 8;
3 DO j=1 to 50;
4 
5 Grade= Grd;
6 IF (Grd=6) THEN DO;
7 IF (ranuni(999) > .80) THEN Grade= .;
8 END;
9 ELSE IF (ranuni(99) > .95) THEN Grade= .;
10 
11 IF (j < 26) THEN Study= 1;
12 ELSE Study= 0;
13 
14 Score0= 70 + 3*rannor(1);
15 IF (Score0 >= 100) THEN Score0= 100 - 10*ranuni(99);
16 
17 Score= Score0 + 2*rannor(99) + 2;
18 IF (Study = 1) THEN DO;
19 Score= Score + 3;
20 IF (Grd = 6) THEN Score= Score + 1;
21 IF (Grd = 8) THEN Score= Score + 3;
22 END;
23 
24 OUTPUT;
25 END; END;
26 drop Grd j;
27RUN;
2 Code Block
PROC PRINT
Explanation :
Display of the first 10 observations of the generated dataset for verification.
Copied!
1PROC PRINT DATA=Mono2(obs=10);
2 var Grade Score0 Score Study;
3 title 'First 10 Obs in the Student Test Data';
4RUN;
3 Code Block
PROC MI Data
Explanation :
Execution of multiple imputation. The 'nimpute=20' option creates 20 imputed datasets. The 'mnar' statement adjusts the imputed values for the 'Grade' variable (when the event is '6') with a shift of 2, assuming a non-random missing data mechanism.
Copied!
1PROC MI DATA=Mono2 seed=34857 nimpute=20 out=outex17;
2 class Study Grade;
3 monotone logistic (Grade / link=glogit);
4 mnar adjust( Grade (event='6') /shift=2);
5 var Study Score0 Score Grade;
6RUN;
4 Code Block
PROC PRINT
Explanation :
Display of the imputation results ('outex17' dataset), notably showing the imputation number.
Copied!
1PROC PRINT DATA=outex17(obs=10);
2 var _Imputation_ Grade Study Score0 Score;
3 title 'First 10 Observations of the Imputed Student Test Data Set';
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


Related Documentation

Aucune documentation spécifique pour cette catégorie.