options ls=80; data soo1; input z h12 e12 h22 c22 e22; put ' z = ' z ' h12 = ' h12 ' e12 = ' e12 ' h22 = ' h22 ' c22 = ' c22 ' e22 = ' e22; h1 = sqrt(h12); e1 = sqrt(e12); h2 = sqrt(h22); c2 = sqrt(c22); e2 = sqrt(e22); do i = 1 to 10000; ash1 = rannor(0); ash2 = rannor(0); a11 = sqrt(z)*ash1 + sqrt(1-z)*rannor(0); a21 = sqrt(z)*ash1 + sqrt(1-z)*rannor(0); a12 = sqrt(z)*ash2 + sqrt(1-z)*rannor(0); a22 = sqrt(z)*ash2 + sqrt(1-z)*rannor(0); ec2 = rannor(0); ew11 = rannor(0); ew21 = rannor(0); ew12 = rannor(0); ew22 = rannor(0); vart11 = h1*a11 + e1*ew11; vart21 = h1*a21 + e1*ew21; vart12 = h2*a12 + c2*ec2 + e2*ew12; vart22 = h2*a22 + c2*ec2 + e2*ew22; if vart11 >= 1.96 then pradhd=ranuni(0); if vart12 >= 1.37 then prcd=ranuni (0); if pradhd <= 1 or prcd < .2979 then padhd=1; if vart11 < 1.96 and (vart12 < 1.37 or prcd >=.2979) then padhd=0; if prcd <= 1 then pcd=1; if vart12 < 1.37 then pcd=0; if vart21 >= 1.96 then pradhd=ranuni(0); if vart22 >= 1.37 then prcd=ranuni (0); if pradhd <= 1 or prcd < .2979 then cadhd=1; if vart21 < 1.96 and (vart22 < 1.37 or prcd >=.2979) then cadhd=0; if prcd <= 1 then ccd=1; if vart22 < 1.37 then ccd=0; if padhd=0 and pcd=0 then padhdcd=0; if padhd=1 and pcd=0 then padhdcd=1; if padhd=1 and pcd=1 then padhdcd=2; if padhd=0 and pcd=1 then padhdcd=3; if cadhd=0 and ccd=0 then cadhdcd=0; if cadhd=1 and ccd=0 then cadhdcd=1; if cadhd=1 and ccd=1 then cadhdcd=2; if cadhd=0 and ccd=1 then cadhdcd=3; if padhd=0 and pcd=0 then paddonly=0; if padhd=1 and pcd=0 then paddonly=1; if cadhd=0 and ccd=0 then caddonly=0; if cadhd=1 and ccd=0 then caddonly=1; if padhd=0 and pcd=0 then pcdonly=0; if padhd=0 and pcd=1 then pcdonly=1; if cadhd=0 and ccd=0 then ccdonly=0; if cadhd=0 and ccd=1 then ccdonly=1; file 'rmcdmzck.dat'; put (padhd pcd cadhd ccd padhdcd cadhdcd paddonly caddonly pcdonly ccdonly) (f18.12); output; end; cards; 1 .7 .3 .5 .2 .3 ; run; data test; infile 'rmcdmzck.dat'; input (padhd pcd cadhd ccd padhdcd cadhdcd paddonly caddonly pcdonly ccdonly) (f18.12); if padhd=0 and pcd=0 and cadhd=0 and ccd=0 then f0000=1; if (padhd=0 and pcd=1 and cadhd=0 and ccd=0) or (padhd=0 and pcd=0 and cadhd=0 and ccd=1) then f0100=1; if (padhd=1 and pcd=0 and cadhd=0 and ccd=0) or (padhd=0 and pcd=0 and cadhd=1 and ccd=0) then f1000=1; if (padhd=1 and pcd=1 and cadhd=0 and ccd=0) or (padhd=0 and pcd=0 and cadhd=1 and ccd=1) then f1100=1; if padhd=0 and pcd=1 and cadhd=0 and ccd=1 then f0101=1; if (padhd=1 and pcd=0 and cadhd=0 and ccd=1) or (padhd=0 and pcd=1 and cadhd=1 and ccd=0) then f1001=1; if (padhd=1 and pcd=1 and cadhd=0 and ccd=1) or (padhd=0 and pcd=1 and cadhd=1 and ccd=1) then f1101=1; if padhd=1 and pcd=0 and cadhd=1 and ccd=0 then f1010=1; if (padhd=1 and pcd=1 and cadhd=1 and ccd=0) or (padhd=1 and pcd=0 and cadhd=1 and ccd=1) then f1110=1; if padhd=1 and pcd=1 and cadhd=1 and ccd=1 then f1111=1; if f0000=1 then freq=1; if f0100=1 then freq=2; if f1000=1 then freq=3; if f1100=1 then freq=4; if f0101=1 then freq=5; if f1001=1 then freq=6; if f1101=1 then freq=7; if f1010=1 then freq=8; if f1110=1 then freq=9; if f1111=1 then freq=10; file 'rmcdmzck2.dat'; put freq; output; run; data dummy; infile 'dummy.dat'; input padhd pcd cadhd ccd padhdcd cadhdcd paddonly caddonly pcdonly ccdonly; if padhd=0 and pcd=0 and cadhd=0 and ccd=0 then f0000=1; if (padhd=0 and pcd=1 and cadhd=0 and ccd=0) or (padhd=0 and pcd=0 and cadhd=0 and ccd=1) then f0100=1; if (padhd=1 and pcd=0 and cadhd=0 and ccd=0) or (padhd=0 and pcd=0 and cadhd=1 and ccd=0) then f1000=1; if (padhd=1 and pcd=1 and cadhd=0 and ccd=0) or (padhd=0 and pcd=0 and cadhd=1 and ccd=1) then f1100=1; if padhd=0 and pcd=1 and cadhd=0 and ccd=1 then f0101=1; if (padhd=1 and pcd=0 and cadhd=0 and ccd=1) or (padhd=0 and pcd=1 and cadhd=1 and ccd=0) then f1001=1; if (padhd=1 and pcd=1 and cadhd=0 and ccd=1) or (padhd=0 and pcd=1 and cadhd=1 and ccd=1) then f1101=1; if padhd=1 and pcd=0 and cadhd=1 and ccd=0 then f1010=1; if (padhd=1 and pcd=1 and cadhd=1 and ccd=0) or (padhd=1 and pcd=0 and cadhd=1 and ccd=1) then f1110=1; if padhd=1 and pcd=1 and cadhd=1 and ccd=1 then f1111=1; if f0000=1 then freq=1; if f0100=1 then freq=2; if f1000=1 then freq=3; if f1100=1 then freq=4; if f0101=1 then freq=5; if f1001=1 then freq=6; if f1101=1 then freq=7; if f1010=1 then freq=8; if f1110=1 then freq=9; if f1111=1 then freq=10; file 'dummy2.dat'; put freq; output; run; data freq1; infile 'dummy2.dat'; input freq; data freq2; infile 'rmcdmzck2.dat'; input freq; data freq12; set freq1 freq2; libname dir '.'; proc freq; tables freq / out=dir.rmcdmzp nocum nopercent; run; libname dir '.'; filename data 'premz.frq'; data dir.rmcdmzp; set dir.rmcdmzp; file data; put count 9-16; Run; data premz; infile 'premz.frq'; input countp; count=countp-1; file 'premz.dat'; put count; output; run; data rmcdmz; infile 'premz.dat'; input count; run; data _null_; file "../comorbmx/mz.frq"; put '*'; run; filename data "../comorbmx/mz.frq"; data rmcdmz; set rmcdmz; file data mod; put count 1-16; Run;