- *generating a test data set;
- data a;
- array test{1000};
- do j = 1 to 2000;
- do i = 1 to dim(test);
- r =ceil (ranuni(0)*12);
- r2 =ceil (ranuni(0)*11);
- test{i} = 1+mod(r, 3);
- if r2 = 11 then test{i} = .;
- end;
- output;
- end;
- drop r:;
- run;
- data b;
- set a end = Eof;
- array test{1000}; *load vars;
- array n_{1000}; *count # of non-missing for each var;
- array n1_{1000}; *count # of 1s for each var;
- array n2_{1000}; *count # of 2s for each var;
- array n3_{1000}; *count # of 3s for each var;
- array p1_{1000}; *percentage of 1s for each var;
- array p2_{1000}; *percentage of 2s for each var;
- array p3_{1000}; *percentage of 3s for each var;
- do i = 1 to dim(test);
- if ^missing(test{i}) then
- do;
- n_{i}+1;
- n1_{i}+(test{i} = 1);
- n2_{i}+(test{i} = 2);
- n3_{i}+(test{i} = 3);
- end;
- end;
- if Eof then
- do i = 1 to dim(test);
- p1_{i} = n1_{i} /n_{i};
- p2_{i} = n2_{i} /n_{i};
- p3_{i} = n3_{i} /n_{i};
- end;
- drop i j;
- run;
something wrong with the website, many 's were gone...??


雷达卡





京公网安备 11010802022788号







