Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!psuvax1!psuvm!NPRDC!ALDERTON From: alderton@NPRDC.NAVY.MIL (David Alderton) Newsgroups: bit.listserv.sas-l Subject: squaring std's in a type=cov data set Message-ID: <9002081800.AA23920@nprdc.navy.mil> Date: 8 Feb 90 18:12:19 GMT Sender: "SAS(r) Discussion" Reply-To: alderton@nprdc.navy.mil Lines: 49 Approved: NETNEWS@PSUVM Gateway Folks, I posted a note yesterday about squaring the _numeric_ values of a _type_='std' in a type=cov data set. A few suggestions were made but most people asked me for more information. Below is the code is I working with. I need 4 quantities: (a) the sum of all the elements in the covariance matrix (sumc below), (b) number of subjects in the data set (n below), (c) the number of items entering into the covariance set (k below), and (d) the sum of the variances (sumv below). I can get the first three quantities but haven't been successful getting the sum of the variances. More accurately, I cannot get the standard deviations squared to sum them up. I tried an array but couldn't figure out how to address the _numeric_ elements, and then tried a few variants of directly squaring _numeric_ elements with no success in either case. Here are two things that I tried: 1. if _type_='std' then sumv+sum(of ( _numeric_ * _numeric_ ))-sumc**2; 2. if _type_='std' then sumv+sum(of ( _numeric_)**2)-sumc**2; Both these attempts produce errors, (1) function not known, (2) name exceeds 8 characters. This is driving me crazy!!! Can anyone help me out with this? Thanks, David. =====================SAS V. 5.18 on an IBM 4381 running CMS============== options center nocaps ls=72; cms filedef in disk brad2 raw a; data one; infile in; input idac1-idac3; proc corr data=one cov noprint out=cov (type=cov); data cov; set cov end=endin; retain sumc 0 sumv 0 n k; if _type_='cov' then sumc+sum(of _numeric_)-sumc; 1. if _type_='std' then sumv+sum(of ( _numeric_ * _numeric_ ))-sumc**2; 2. if _type_='std' then sumv+sum(of ( _numeric_)**2)-sumc**2; if _type_='n' then n=(sum(of _numeric_)-sumc-sumv)/ (n(of _numeric_)-2); if _type_='n' then k=n(of _numeric_)-3; if endin=1 then do; alpha = (k/(k-1))*(1-(sumv/sumc)); output; end; run; data calcf; set cov; f = (1-0)/(1-alpha); fprob2 = 1 - probf(of f, n-1, (n-1)*(k-1)); proc print data=calcf; var alpha n k f fprob;