Quantcast
Channel: Statistics Help @ Talk Stats Forum - SAS
Viewing all articles
Browse latest Browse all 310

data generation

$
0
0
Dear Sas users
I want to extend this code.
The 500 person in LC 1 and the other 5020 person in LC 2.
On the other hand, 150 person in c0 should be in LC 1, 150 person in c0 should be in LC2.
350 person in c1 should be in LC1 and 350 person in c1 should be in LC2.
Can you help me about this problem?
/*dif40_cov30_LC50_es50_m0*/
data aa1;
do subject=1 to 287;
c=0;
x1=rannor(0);
lc=1;
output;
end;
do subject=288 to 500;
c=1;
x1=rannor(0);
lc=1;
output;
end;
run;
/* this is where to change N(0,1) to N (1,1)
x2=rannor(0)+1;*/
data aa2;
do subject=1 to 13;
c=0;
x2=rannor(0);
lc=2;output;end;
do subject=13 to 500;
c=1;
x2=rannor(0);
lc=2;output;
end;
run;
/*DIF*/
data g1;
set aa1 ;array b (i) b1-b30;
array prob (i) p1-p30;
b1=1.461;
b2=0.081;
b3=2.101;
b4=0.971;
b5=1.341;
b6=-0.089;
b7=0.271;
b8=-0.979;
b9=-1.309;
b10=-1.859;
b11=-1.479;
b12=0.381;
b13=0.541;
b14=0.901;
b15=1.901;
b16=-0.399;
b17=0.021;
b18=-0.619;
b19=0.001;
b20=0.331;
b21=-0.599;
b22=-1.509;
b23=-0.189;
b24=-0.159;
b25=-0.029;
b26=-0.769;
b27=-0.019;
b28=-0.499;
b29=0.851;
b30=-0.649;
do i=1 to 30;
prob=(exp(x1-b))/(1+ exp(x1-b));
end;
run;
data g2;
set aa2;array prob (ii) p1-p30;
array bb (ii) bb1-bb30;
bb1=1.861;
bb2=0.481;
bb3=2.881;
bb4=1.751;
bb5=2.121;
bb6=0.691;
bb7=1.051;
bb8=-0.199;
bb9=-0.529;
bb10=-1.079;
bb11=-0.699;
bb12=1.161;
bb13=0.021;
bb14=0.381;
bb15=1.381;
bb16=-0.919;
bb17=-0.499;
bb18=-1.139;
bb19=-0.519;
bb20=-0.189;
bb21=-1.119;
bb22=-2.029;
bb23=-0.709;
bb24=-0.679;
bb25=-0.549;
bb26=-1.289;
bb27=-0.539;
bb28=-1.019;
bb29=0.331;
bb30=-1.169;
do ii=1 to 30;
prob=(exp(x2-bb))/(1+ exp(x2-bb));
end;
run;
/* mut */
data respg1;
set g1;
array prob (j) p1-p30;
array resp (j) r1-r30;
do j=1 to 30;
x=ranuni(0);
if x le prob then resp=1; else resp=0;
/*where le means `less than or equal to'*/
end; run;
data respg2;
set g2;
array prob (j) p1-p30;
array resp (j) r1-r30;
do j=1 to 30;
x=ranuni(0);
if x le prob then resp=1;
else resp=0;
end;
run;
/*proc means data=aa1;run;proc means data=aa2;run;*/
data response;
SET respG1 respG2;
rand=ranuni(0);
*1000000;
drop x1 x2 x subject b1-b30 bb1-bb30 i ii j p1-p30;
run;
proc sort data=response;
by rand;
run;
data _Null_;
set response;
FILENAME OUTDATA 'C:\en\u.DAT';
FILE OUTDATA NOTITLES NOPRINT;
put (R1-R30 c )(@1 31*2. );
run;
data _Null_;
set response;
FILENAME OUTDATA 'C:\en\uu.DAT';
FILE OUTDATA NOTITLES NOPRINT;
put (R1-R30 c rand lc )(@1 31*2. @63 7. @70 2.);
run;

Viewing all articles
Browse latest Browse all 310

Trending Articles