Hi, I would echo Bert's comments below.
The last thing that you want to try to do is to convert SAS code to R code on a "line for line" basis. The programming paradigm of R, which is built upon vectorized operations, takes a "whole object" approach for efficiency. SAS does not, since it is generally based upon 1970's era, main frame style, programming techniques using macros, etc. If this is not a one off and something that you might find yourself doing with some frequency, you might consider investing in Bob Muenchen's book, R for SAS and SPSS Users: https://www.amazon.com/gp/product/1461406846/ <https://www.amazon.com/gp/product/1461406846/> While it is now a few years old, it is still relevant in terms of pointing you in the direction of basic and conceptual linkages between the languages. Regards, Marc Schwartz > On Sep 29, 2017, at 2:09 PM, Bert Gunter <bgunter.4...@gmail.com> wrote: > > I will offer an opinion, with which others may fairly take issue. > > If you are coming from SAS and wish to learn R, you should forget about SAS > entirely; it is ancient and convoluted. But more to the point, as others > have already suggested, you will only confuse and hamstring yourself trying > to convert the programming paradigms of one language into another. Better > to consider the **tasks** you wish to accomplish and learn how to approach > them in the new language. I would add that this especially includes > learning about R's varied data structures for which there is no cognate in > SAS I think (correction requested if I'm wrong about this). > > If this is a one-off, just finding a local resource to do the job for you > might be the best approach. > > Cheers, > Bert > > > > > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along and > sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > On Fri, Sep 29, 2017 at 10:21 AM, Kevin E. Thorpe <kevin.tho...@utoronto.ca> > wrote: > >> Regarding point 3, as a moderator I have been helping Andrew get this post >> out to the list over the past week. His previous attempts were encoded in >> some way that the listserv rejected. He sent me the post via his gmail >> account and viewing the source I saw it had at least both plain test and >> HTML an I said it was worth a try to post it. Certainly on my mail client >> his post displays acceptably with the notice that the HTML alternative was >> removed. >> >> Kevin >> >> On 09/29/2017 09:51 AM, Michael Dewey wrote: >> >>> You might get better answers if you >>> >>> 1 - break this down into separate issues >>> 2 - tell us what you want to achieve in words rather than SAS, we all >>> read English but few of us speak SAS >>> 3 - post in plain text not HTML as HTML mangles your post >>> >>> On 29/09/2017 13:47, Andrew Harmon wrote: >>> >>>> Hello all, >>>> >>>> My statistical analysis training up until this point has been entirely >>>> done >>>> in SAS. The code I frequently used was: >>>> >>>> *Yield Champagin; >>>> >>>> data yield; >>>> >>>> set stress; >>>> >>>> if field='YV' then delete; >>>> >>>> if field='HB' then delete; >>>> >>>> if barcode='16187DD4015' then delete; >>>> >>>> if barcode='16187DD6002' then delete; >>>> >>>> if barcode='16187DD2007' then delete; >>>> >>>> if barcode='16187DD5016' then delete; >>>> >>>> if barcode='16187DD8007' then delete; >>>> >>>> if barcode='16187DD7010' then delete; >>>> >>>> if barcode='16187DD7007' then delete; >>>> >>>> if barcode='16187DD8005' then delete; >>>> >>>> if barcode='16187DD6004' then delete; >>>> >>>> if barcode='16187DD5008' then delete; >>>> >>>> if barcode='16187DD7012' then delete; >>>> >>>> if barcode='16187DD6010' then delete; >>>> >>>> run; quit; >>>> >>>> >>>> >>>> Title'2016 Asilomar Stress Relief champagin yield'; >>>> >>>> proc mixed method=reml data=yield; >>>> >>>> class rep Management Foliar_Fungicide Chemical_Treatment; >>>> >>>> model Grain_Yield__Mg_h_ =Management|Foliar_Fungicide|Chemical_Treatment >>>> Final_Stand__Plants_A_ / outpred=resids residual ddfm=kr; >>>> >>>> random rep rep*Management rep*Management*Foliar_Fungicide; >>>> >>>> lsmeans Management|Foliar_Fungicide|Chemical_Treatment / pdiff; >>>> >>>> ods output diffs=ppp lsmeans=means; >>>> >>>> ods listing exclude diffs lsmeans; >>>> >>>> run; quit; >>>> >>>> %include'C:\Users\harmon12\Desktop\pdmix800.sas'; >>>> >>>> %pdmix800(ppp,means,alpha=0.10,sort=yes); >>>> >>>> ods graphics off; >>>> >>>> run; quit; >>>> >>>> proc univariate data=resids normal plot; id Barcode Grain_Yield__Mg_h_ >>>> pearsonresid; var resid; >>>> proc print data=resids (obs=3);run; >>>> >>>> Can someone please help me convert my code to R? Any help would be much >>>> appreciated. >>>> >>>> >>>> Thanks, >>>> >>>> >>>> Andrew Harmon >>>> >>>> [[alternative HTML version deleted]] [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.