[R] sas to r

From: Greg Adkison <gadkison_at_email.wcu.edu>
Date: Sat 17 Jul 2004 - 08:18:10 EST


I would be incredibly grateful to anyone who'll help me translate some SAS code into R code.

Say for example that I have a dataset named "dat1" that includes five variables: wshed, site, species, bda, and sla. I can calculate with the following SAS code the mean, CV, se, and number of observations of "bda" and "sla" for each combination of "wshed," "species," and "site," restricting the species considered to only three of several species in dat1 (b, c, and p). Moreover, I can output these calculations and grouping variables to a dataset named "dat2" that will reside in RAM and include the variables wshed, site, species, mBdA, msla, cBda, sBdA, ssla, nBda, and nsla.

proc sort data=dat1;
  by wshed site species;
proc means data=dat1 noprint mean cv stderr n;   by wshed site species;
  where species in ('b', 'c', 'p');
  var BdA sla;
  output out=dat2
    mean=mBdA msla

    cv=cBdA csla
    stderr=sBdA ssla
    n=nBdA nsla;

Thanks,
Greg



R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jul 17 08:28:08 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 02:36:40 EST