*************************************************** * Random number generator for Research Methods * Input simple ANOVA and regression designs with * parameters. The program generates data that * fit the design and parameters. ***************************************************; proc iml; *ANOVA: independent variables are catagorical; ***********************************************; ***** Input design and parameters ************* ***********************************************; *How many Independent variables?*************; *Input the number of IVs*********************; IVk = 2; ***How many levels for each independent variable?**; *How many levels for independent variable 1?; IVLS1 = 2; *This will be the number of COLUMNS; *IV1 for columns for means. *How many levels for independent variable 2?; *Type 1 if there is no second IV; IVLS2 = 2; *This will be the number of ROWS for means.; Means = j(IVLS2,IVLS1,0); *placeholder for means; *What is the population SD?; SD = 66; **For ANOVA, there should be only one SD (homogeneity of variance); * What are the means for each cell?; **If there should be no negative numers, **make sure that the means are at least 3 SDs above zero; * The layout for Means is Means[row, column]. * Put in one entry for each cell of the design; Means[1,1] = 912; Means[1,2] = 780; Means[2,1] = 1086; Means[2,2] = 912; print means; *feedback on what you input; *What is the sample size? How many participants PER CELL; N = 25; *Set placeholder for data; *we need one column for the DV and one for each IV); data = j(1,(IVk+1),0); ****************************************** * generate data ******************************************; do I = 1 to IVLS1; do L = 1 to IVLS2; CellID1 = j(N,1,I); *keeps track of which cell to label for ANOVA; CellID2 = j(N,1,L); Celldat = normal(j(N,1,0)); *unit normal (z) random data; Celldat = Celldat#SD+Means[L,I]; *adjust the mean and SD for the desired scale; Celldat = round(Celldat); *round to eleminate decimals - can be eliminated if you need decimals; Celldat = Celldat||CellID1; *append the cell label for IV1 to the data; if IVLS2 > 1 then do; Celldat = Celldat||CellID2; end; *append cell label for IV2 to data; data = data//celldat; *append the new data to the old data; end; *IVLS2 loop - row, iv2; end; *IVLS1 loop - column, iv1; * print data; *********************************************** * Output data ***********************************************: ** Create output dataset**; Create out1 from data; append from data; quit; data d1; set out1; if _N_ eq 1 then delete; proc print; *proc means; *var col1; *by col2; proc glm; class col2 col3; model col1=col2 col3 col2*col3; data last; set d1; * replace the FILE path with one that works for your computer; file 'C:\Users\mbrannick\Desktop\anova1'; put (col1 col2 col3) (8.2); run;