Date: Fri, 2 Sep 2005 12:39:31 -0700 kachi "SAS(r) Discussion" kachi http://groups.google.com Re: Help on Special Variance Calculation To: sas-l@uga.edu <1125667859.611747.45140@f14g2000cwb.googlegroups.com> text/plain; charset="iso-8859-1"

Keppeler,

I give another data step approach to your problem making use of SAS's computing abilities. There are several PROCs giving Corrected Sum of Squares (CSS) and I use TABULATE.

[1] First compute the CSS for each teacher and the total CSS for all teachers within a given school. This is given in each row of the table generated by TABULATE.

[2] Find the difference between the total CSS and a specific teacher CSS within each school. This is the CSS for 90 students of other 9 teachers. Divide it by DF of 89 to get the variance sought for. There will not a big difference if 90 is used but it is always a good practice to do.

1 data one; 2 do schoolID=1 to 10; 3 do teachID=1 to 10; 4 do studentID=1 to 10; 5 score=ranuni(11)*100; 6 output; 7 end; 8 end; 9 end; 10 run;

NOTE: The data set WORK.ONE has 1000 observations and 4 variables. NOTE: DATA statement used: real time 0.03 seconds cpu time 0.03 seconds

11 ods output table=work.table1(keep=schoolID teachID Score_CSS); 12 proc tabulate data = one format=9.2 ; 13 class schoolID teachID; 14 var score; 15 table schoolID='' , CSS='Corrected Sum of Squares by Teacher'*score='' *(teachID='' 15 ! all) 16 /BOX='School' rts=8; 17 run;

NOTE: The data set WORK.TABLE1 has 110 observations and 3 variables. NOTE: There were 1000 observations read from the data set WORK.ONE. NOTE: PROCEDURE TABULATE used: real time 0.07 seconds cpu time 0.07 seconds

18 ods output close;

[3] The dataset generated by ODS output table, table1, has 110 rows of which the last 10 rows are the total CSS for each of 10 schools. The rest 100 rows are for the school-teacher combinations. I am reading those lines to table, total.

19 data total(keep=score_CSS rename=(score_CSS=tscore)); 20 set table1 (firstobs=101 obs=110); 21 run;

NOTE: There were 10 observations read from the data set WORK.TABLE1. NOTE: The data set WORK.TOTAL has 10 observations and 1 variables. NOTE: DATA statement used: real time 0.03 seconds cpu time 0.03 seconds

[4] Using double setting both the Table the Variances are computed. The table wanted gives variance by teacher by school.

22 data wanted; 23 if _N_ > 100 then stop; 24 set table1; 25 i = mod(_N_, 10); 26 if i = 0 then i = 10; 27 set total point = i; 28 variance = (tscore - score_CSS) / 89; 29 run;

NOTE: There were 100 observations read from the data set WORK.TABLE1. NOTE: The data set WORK.WANTED has 100 observations and 5 variables. NOTE: DATA statement used: real time 0.03 seconds cpu time 0.03 seconds

30 proc print data = wanted; 31 run;

NOTE: There were 100 observations read from the data set WORK.WANTED. NOTE: PROCEDURE PRINT used: real time 0.01 seconds cpu time 0.01 seconds

[5] There may be more elegant solution to this and I wish other members to follow me.

Regards, Muthia Kachirayan

Back to: Top of message | Previous page | Main SAS-L page