/* TESTMIST.SAS * Test program for MISTRESS.SAS macro * Note: Example 2 is a computationally intensive analysis. * Stef van Buuren, 25 nov. 1992 */ %include 'md/mistress.sas'; /* <--- specify proper path here */ /* Example 1: Table 1 of Van Buuren & Van Rijckevorsel (1992) */ data table1; length income age $6 car $3; input id 1-2 income 4-9 age 11-16 car 18-20; cards; 1 young jpn 2 middle middle am 3 old am 4 low young jpn 5 middle young am 6 high old am 7 low young jpn 8 high middle am 9 high am 10 low young am ; proc print data=table1; /* input: _last_=table1, output=imputed */ %mistress(var=_CHAR_) proc print data=imputed; run; /* Example 2: Table 2 of Van Buuren & Van Rijckevorsel (1992) */ data lso; input @1 (d h r s n) (1.) w 6-9 @; job='MAN'; output; input @1 (d h r s n) (1.) w 10-13 @; job='ADM'; output; input @1 (d h r s n) (1.) w 14-17 @; job='COM'; output; input @1 (d h r s n) (1.) w 18-21 @; job='SCI'; output; input @1 (d h r s n) (1.) w 22-25 @; job='SER'; output; input @1 (d h r s n) (1.) w 26-29 @; job='AGR'; output; input @1 (d h r s n) (1.) w 30-33 @; job='IND'; output; input @1 (d h r s n) (1.) w 34-37; job=' '; output; cards; 11111 1 1 1 6 2 5 64 19 11110 0 0 0 6 3 7 11 10 10111 1 1 0 3 3 1 21 6 01111 0 0 0 1 1 1 3 0 11101 0 1 1 1 1 3 61 23 11011 0 1 1 4 6 4 50 15 10110 0 1 2 1 0 2 8 5 01110 0 1 0 0 0 1 2 1 11100 1 1 0 9 2 9 51 22 11010 0 1 1 9 2 20 13 20 00111 0 3 2 2 0 0 12 4 10101 0 0 2 1 1 1 20 12 10011 4 3 2 6 3 2 46 32 01101 0 0 1 2 1 0 8 7 11001 2 6 4 6 9 12 88 32 01011 0 0 0 1 0 0 5 2 00110 0 0 0 1 1 0 2 3 10100 0 1 0 1 4 3 14 10 10010 0 2 1 2 2 13 17 10 01100 0 0 3 6 0 1 10 9 01010 0 1 0 3 4 0 4 3 11000 2 6 16 21 38 81 95 81 00101 1 16 3 10 6 2 15 14 00011 3 19 6 16 6 0 28 29 10001 8 11 6 20 14 10 103 48 01001 2 4 12 19 21 4 40 16 00100 3 5 7 27 12 2 29 19 10000 4 15 28 32 25 60 104 96 00010 6 22 3 27 8 1 17 25 01000 2 12 58 115 87 16 80 71 00001 21 133 40 132 54 3 125 122 00000 157 843 373 916 349 54 324 816 ; %mistress(data=lso, var=_ALL_, wgtvar=w, idle=-1) proc catmod data=imputed; model job = d h r s n/freq noiter nodesign noparm; run; /* Example 3: Little and Rubin, p. 187 */ data lr; length clinic $1 precare $4 died $3; input clinic 1-1 precare 3-6 died 8-10 count 12-14; cards; A less yes 3 A less no 176 A more yes 4 A more no 293 B less yes 17 B less no 197 B more yes 2 B more no 23 less yes 10 less no 150 more yes 5 more no 90 ; proc freq data=lr; weight count; tables clinic * precare * died / nocol norow nocum nopercent missprint; %mistress(var={clinic precare died count}, wgtvar=count) proc freq data=imputed; tables clinic * precare * died / nocol norow nocum nopercent missprint; run;