Dieter Menne wrote:


P.Dalgaard wrote:

IF TYPE='TRUCK' and count=12 THEN VEHICLES=TRUCK+((CAR+BIKE)/2.2);
vehicles <- ifelse(TYPE=='TRUCK' & count=12, TRUCK+((CAR+BIKE)/2.2), NA)



Read both versions to an audience, and you will have to admit that this is
one of the cases where SAS is superior.

Dieter



That's not entirely clear. For instance, SAS is not being clear about what happens when the condition is FALSE.

SAS is also not distinguishing comparison and assignment, but then again you don't accidentally do count=12 when you mean count==12....

As a generic matter, SAS (the DATA step) is generally good at things that are done by sequential sweeps through a data file. The shortcomings come in when you do things that can't be done sequentially, or require substantial rearranging of data first. x - ave(x,g,median) is an example which IIRC requires

proc sort
proc means by group (saving medians to data set)
data step (merge and subtract)

On the third (!) hand, some other things require rethinking in R that are easily expressed in a sequential setting. "Last observation carried forward" comes to mind (notwithstanding theoretical issues of that procedure).


--
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalga...@biostat.ku.dk)              FAX: (+45) 35327907

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to