comp.soft-sys.sas - The SAS statistics package.
Hello All. I have read the manuals and other sources of information. What is the difference between the ID and Class statements of PROC Summary? Thanks In Advance=20
Hi SASLs, My data has multi-measurement by drug for each ID. I want to calculate the = mean for the same drug for each ID when each ID has multi-values for each d= rug. When I do the below code, sometimes for the same ID, the mean is combi= ned both difference drug. Can someone help me on figure out the error of my= code? Thanks much! my data is: id=A0 drug var1 1=A0=A0 a=A0=A0=A0=A0 0.3 1=A0=A0 a=A0=A0=A0=A0 0.4 1=A0=A0 b=A0=A0=A0=A0 1.1 1=A0=A0 b=A0=A0=A0=A0 0.8 1=A0=A0 b=A0=A0=A0=A0 0.7 I want: id=A0 drug var1 =0A1=A0=A0 a=A0=A0=A0 =A0=A0 0.3 =0A1=A0=A0 a=A0=A0=A0 =A0=A0 0.4 1=A0=A0 mean=A0 0.35 =0A1=A0=A0 b=A0=A0=A0=A0=A0=A0=A0 1.1 =0A1=A0=A0 b=A0=A0=A0=A0=A0 =A0 0.8 =0A1=A0=A0 b=A0=A0=A0=A0=A0=A0=A0 0.7 1=A0=A0 mean=A0 0.87 My code:=20 data want (drop=3Dtot ); do until(last.id); set want; by id drug; tot=3Dsum(0, tot, var1); N=3Dsum(n,n(var1)); output; end; var1=3Dtot/n; drug=3D'mean_var1'; output; title 'calculate mean of var1 by patient and by drug'; run; The results of above code are:=20 id=A0 drug var1 =0A=0A1=A0=A0 a=A0=A0=A0 =A0=A0 0.3 =0A=0A1=A0=A0 a=A0=A0=A0 =A0=A0 0.4 =0A1=A0=A0 b=A0=A0=A0=A0=A0=A0=A0 1.1 =0A=0A1=A0=A0 b=A0=A0=A0=A0=A0 =A0 0.8 =0A=0A1=A0=A0 b=A0=A0=A0=A0=A0=A0=A0 0.7 =0A1=A0=A0 mean=A0=20 It combine the a and b for the same ID.=20 Jane --- On Thu, 5/14/09, Data _null_; < XXXX@XXXXX.COM > wrote: From: Data _null_; < XXXX@XXXXX.COM > Subject: Re: what is the correct 'Mean' statement in SAS for calulcating me= an by ID with multiple measurement/var To: "jn mao" < XXXX@XXXXX.COM > Cc: XXXX@XXXXX.COM Date: Thursday, May 14, 2009, 11:58 AM You can't use the MEAN function in a vertical fashion as you are trying to do. You must sum then get mean. I would not use data step to summarize data.=A0 The mistake you made is a good example of the reason why. data wk; =A0=A0=A0input id var1; =A0=A0=A0cards; 1=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0=A00.551724138 1=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0=A00.333333333 1=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0=A00.12345679 ;;;; =A0=A0=A0run; proc means; * check; =A0=A0=A0var var1; =A0=A0=A0run; data want; =A0=A0=A0do until(last.id); =A0 =A0 =A0 set wk; =A0 =A0 =A0 by id; =A0 =A0 =A0 sum=3Dsum(sum,var1); =A0 =A0 =A0 N=A0 =3Dsum(n,n(var1)); =A0 =A0 =A0 output; =A0 =A0 =A0 end; =A0=A0=A0var1=3Dsum/n; =A0=A0=A0category=3D'mean_var1'; =A0=A0=A0output; =A0=A0=A0stop; =A0=A0=A0title 'calculate mean of var1 by ID'; =A0=A0=A0run; proc print; =A0=A0=A0run; On 5/14/09, jn mao < XXXX@XXXXX.COM > wrote: > Hello SAS-Ls, > > I need to calculate the mean by ID when each ID has multiple measurement = on Var1, below is my code. But when I convert it excel file, by manually re= -calculate the mean for each ID, the results are always not the same, can a= nyone help me figure it out? Thanks much. > > Here is SAS code: > > data want (drop=3Davgra); > do until(last.id); > set wk; > by id; > avgra=3Dmean(avgra, var1); > output; > end; > var1=3Davgra; > category=3D'mean_var1'; > output; > title 'calculate mean of var1 by ID'; > run; > > For eg. with above code, for ID1 I got, > id=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 var1 > 1=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0=A00.551724138 > 1=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0=A00.333333333 > 1=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0=A00.12345679 > mean_sas=A0 =A0 =A0 =A0 0.282992763 > > But in Excel/manual, mean=3D0.33 > > Why?, does the Mean statement wrong? Thanks, > > Jane > > > > > > > =0A=0A=0A
Hi all! I've always wondered what is the difference between CLASS and BY statements in a MEANS procedure or in a SUMMARY procedure. And why does BY statement requires the variable to be sorted and CLASS does not? Thanks!
Hello, Following M. Zack remark, the answer that I got here is for the intra class correlation and not for the inter class correlation,sorry about that ---------------------------------------Previous message------------------------------------------------- I have asked the below question weeks ago, and I have addressed the same questions to our fiends Dale and Matthew, but I did not have a response about this, Matthew gave me some ideas which allows me to investigate the problem . And I have the following answer about my question and I would to have your feedback (this is the intraclass correlation) Su2 is the amount of variation due to the random effect (random residual) Se2 is the amount of variation due to the fixed effect (fixed residual) Su2 + Se2 is the total variation rho = Su2/(Su2 + Se2) the fraction of residual variability that can be ascribed to level two Su2 and Se2 can be obtained from the covariance matrix of parameter estimates in the NLMIXED procedure And what will be the inter class correlation, big challenge, is not it? My first question to the list: I would like to ask if there is any possibility in SAS, to estimate or to compute, the Inter class correlation estimate, or the fraction of residual variability of the level 2, in NLMIXED when the dependent variable is binary. Since we got the S2 , the variance of the random effect, but I think it is useful to interpret this quantity as a correlation. Thank you very much in advance for any suggestion. Adel --------------------------------- Douvrez le nouveau Yahoo! Mail : 1 Go d'espace de stockage pour vos mails, photos et vids ! Crz votre Yahoo! Mail