```Date: Mon, 19 May 2008 16:13:36 -0500 Reply-To: Mary Sender: "SAS(r) Discussion" From: Mary Subject: Re: Variance function in IML Comments: To: "P. Cristian Gugiu" Content-Type: text/plain; charset="iso-8859-1" Christian, I didn't find where you could do these a variance or standard deviation directly on a matrix (though it seems that you could apply the formula to a matrix with other functions). I did find that you could do it from data sets, and then use the opt{save} option in the summary to save it; the name of the matrix with the results is the variable name. data test; infile cards; input x; cards; 10 20 30 40 50 run; proc iml; start mod1; use test; summary var {x} stat{std} opt{save}; print x; finish; run mod1; run; Producing Summary Statistics Summary statistics on the numeric variables of a SAS data set can be obtained with the SUMMARY statement. These statistics can be based on subgroups of the data by using the CLASS clause in the SUMMARY statement. The SAVE option in the OPT clause enables you to save the computed statistics in matrices for later perusal. For example, consider the following statement. > summary var {height weight} class {sex} stat{mean std} opt{save}; SEX Nobs Variable MEAN STD ------------------------------------------------ F 9 HEIGHT 60.58889 5.01833 WEIGHT 90.11111 19.38391 M 9 HEIGHT 64.45556 4.90742 WEIGHT 110.00000 23.84717 All 18 HEIGHT 62.52222 5.20978 WEIGHT 100.05556 23.43382 ------------------------------------------------ This summary statement gives the mean and standard deviation of the variables HEIGHT and WEIGHT for the two subgroups (male and female) of the data set CLASS. Since the SAVE option is set, the statistics of the variables are stored in matrices under the name of the corresponding variables, with each column corresponding to a statistic requested and each row corresponding to a subgroup. Two other vectors, SEX and _NOBS_, are created. The vector SEX contains the two distinct values of the class variable SEX used in forming the two subgroups. The vector _NOBS_ has the number of observations in each subgroup. Note that the combined means and standard deviations of the two subgroups are displayed but are not saved. More than one class variable can be used, in which case a subgroup is defined by the combination of the values of the class variables. -Mary ----- Original Message ----- From: P. Cristian Gugiu To: SAS-L@LISTSERV.UGA.EDU Sent: Monday, May 19, 2008 3:26 PM Subject: Variance function in IML Is there a variance function in IML? I have a matrix A. I am trying to calculate a 99% CI for the mean value. I know how to get the mean, A[:]. How can I calculate the variance or standard deviation of A? I know I can save the matrix as a dataset and calculate these summary stats the old- fashioned way. However, I would prefer to do everything in Iml. Thanks, Cristian ```

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