my teachers doesnt understand R and I don't know how to use SAS. Anyone interested in translating my codes to test whether your SAS codes are as good as R??? I can test it on SAS codes once you have translated it .... regards:working: -- View this message in context: http://old.nabble.com/Translation-from-R-codes-to-SAS.-tp26486117p26486117.html Sent from the R help mailing list archive at Nabble.com.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20091123/098c768e/attachment-0001.pl>
You should really learn at least basic SAS yourself. Don't abandon R, but if you use R only because it is the only program you know, then you are making an uninformed decision. If you learn SAS and still prefer R (I do) then it is an informed decision and much better. And your teachers are not the only ones still using SAS, when you go out into the real world and try to get a job you will probably be working with people who use SAS, SPSS, Stata, Statit, etc. Potential employers will not be interested in hiring you if they will need someone else to translate for you when you work with others. Personally, I think that every statistics graduate should be familiar (not necessarily expert) with at least 3 different stats packages. I ask about different packages when I am interviewing job candidates. If someone knows 3 or more, then I can be fairly confident that they could learn another if needed. If they only know 1 (even if it is my favorite and suggested one (R)), then I don't know if they will be able to use any other tools or communicate reasonably with other researchers who use a different package. So take this opportunity to learn at least the basics of SAS (and pick up something else as well), then make the informed decision as to which is your preferred program and also have the skills to collaborate with others. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of ychu066 > Sent: Monday, November 23, 2009 2:35 PM > To: r-help at r-project.org > Subject: [R] Translation from R codes to SAS. > > > my teachers doesnt understand R and I don't know how to use SAS. > Anyone interested in translating my codes to test whether your SAS > codes are > as good as R??? > I can test it on SAS codes once you have translated it .... > > > > regards:working: > -- > View this message in context: http://old.nabble.com/Translation-from-R- > codes-to-SAS.-tp26486117p26486117.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.
ychu066 wrote:> > my teachers doesnt understand R and I don't know how to use SAS. > Anyone interested in translating my codes to test whether your SAS codes > are as good as R??? > I can test it on SAS codes once you have translated it .... > > > > regards:working: >It is quite easy to convert R to SAS IML. Here is an example of R/S+ code and SAS IML code. It is not exactly the same problem but is very colse. I find IML has much of the same functiionality of R, but R blows SAS away with the 2000+ packages out there. R/S+ CODE a=c(2,2,1,0,1,0,1,5,1,1,0,2,2,2,2,1,1,2,3,0,0,0,1,1,0,2,1,1,1,1,0,1,0,1,1,1,1,0,1,1,15,27,0,0,0,0,0,0) b=c(355,389,773,213,231,43,120,105,381,283,294,561,276,416,393,202,103,210,135,196,122,175,55,38,561,114,147,230,88,167,116,1171,706,203,287,253,313,162,441,393,2620,1429,101,232,70,25,196,676) c=c(0,1,1,1,0,1,0,2,0,0,1,0,1,0,1,1,2,0,1,0,1,1,0,0,2,3,0,0,0,0,0,0,0,2,0,0,0,0,0,0,9,41,0,0,0,0,0,0) d=c(176,206,184,108,116,46,124,112,384,135,301,142,278,212,197,105,97,107,138,96,119,172,58,38,274,108,143,242,88,172,61,377,325,183,280,272,154,160,112,124,2625,2854,51,115,75,24,195,225) n <- a+b+c+d Rr <- (c+d)/(a+b) k.T <- 1/(Rr+1) k.C <- Rr/(Rr+1) OR.i <- ((a+k.T)*(d+k.C))/((b+k.T)*(c+k.C)) varlnOR.i <- 1/(a+k.T)+1/(b+k.T)+1/(c+k.C)+1/(d+k.C) w.i <- 1/varlnOR.i plogOR.i <- sum(w.i*log(OR.i))/sum(w.i) pvarlogOR.i <- 1/sum(w.i) pOR.iv.i <- exp(plogOR.i) l.pOR.iv.i <- exp(plogOR.i-qnorm(.975)*sqrt(pvarlogOR.i)) u.pOR.iv.i <- exp(plogOR.i+qnorm(.975)*sqrt(pvarlogOR.i)) SAS CODE Just to read a bunch of columns rom s SAS dataset(dataframe in R) use inv1st(keep=Key) ;read all var _num_ into keyxpo; use inv1st(keep=TrtEvn) ;read all var _num_ into axpo; use inv1st(keep=TrtNonEvn);read all var _num_ into bxpo; use inv1st(keep=CtlEvn) ;read all var _num_ into cxpo; use inv1st(keep=CtlNonEvn);read all var _num_ into dxpo; /* Vertical to horizontal */ a=axpo`; * The apostrophe means transpose; b=bxpo`; c=cxpo`; d=dxpo`; key=keyxpo`; Rr=(c+d)/(a+b); * ratio of control vs trtment group sizes; k_T=1/(Rr+1); k_C=Rr/(Rr+1); OR_C_R = ((a+k_T)#(d+k_C))/((b+k_T)#(c+k_C)); VAR_OR_C_R = 1/(a+k_T) + 1/(b+k_T) + 1/(c+k_C) + 1/(d+k_C); W_R = 1/VAR_OR_C_R; LOG_OR_IV_R = sum(W_R#log(OR_C_R))/sum(W_R); VAR_LOG_OR_IV_R = 1/sum(W_R); OR_IV_R = exp(LOG_OR_IV_R); OR_IV_UP_R = exp(LOG_OR_IV_R + probit(.975)#sqrt(VAR_LOG_OR_IV_R)); OR_IV_LOW_R = exp(LOG_OR_IV_R - probit(.975)#sqrt(VAR_LOG_OR_IV_R)); CC_TA=shape({0},1,3,0); CC_TA= OR_IV_R||OR_IV_LOW_R||OR_IV_UP_R; create CC_TA from CC_TA;append from CC_TA; -- View this message in context: http://n4.nabble.com/Translation-from-R-codes-to-SAS-tp819110p932816.html Sent from the R help mailing list archive at Nabble.com.