freebird2008
11-17-2008, 01:01 PM
Can someone tell me what function to use to return the chi-square value? I want something that will take an array of values and return the chi-square.
|
View Full Version : SAS Chi-square Test freebird2008 11-17-2008, 01:01 PM Can someone tell me what function to use to return the chi-square value? I want something that will take an array of values and return the chi-square. malone73 11-18-2008, 03:53 PM Could you please clarify whether you are looking for a procedure or to do it within a data step through a function? ladybugblue 11-18-2008, 03:57 PM I am pretty sure you can use the proc freq procedure as follows: PROC FREQ; TABLES *** * YearsEducation/chisq; run; freebird2008 11-18-2008, 07:58 PM What I need is a function that will return the double sum of (Oij - eij)^2/eij where Oij is the observed frequency and eij is the expected frequency. Also we get our values from a probrobility table. malone73 11-19-2008, 03:33 AM If that is the case then you need to use PROC FREQ: proc freq data=dataset noprint; tables var1*var2 / outexpected out=output_dataset; run; Option "outexpected" outputs the expected frequency in the dataset specified in option "out=". To automate the calculations you could use a macro which takes the name of the dataset and the variables you want to cross-tabulate. Then you will have to use a DATA STEP to complete your calculations. freebird2008 11-19-2008, 10:02 AM How do I store the value into a variable x? freebird2008 11-19-2008, 01:42 PM I guess what I really need to know is how to write a macro that will return a variable. |