Skip to content
Back to formatted view

Raw Message

Message-ID: <37A5788F-CB60-40FD-8800-9B60AE7FC3BF@me.com>
Date: 2012-08-24T19:06:13Z
From: Marc Schwartz
Subject: if then in R versus SAS
In-Reply-To: <1345831424977-4641225.post@n4.nabble.com>

On Aug 24, 2012, at 1:03 PM, ramoss <ramine.mossadegh at finra.org> wrote:

> I am new to R and I have the following SAS statements:
> 
> if otype='M' and ocond='1' and entry='a.Prop' then MOC=1;
> else MOC=0;
> 
> How would I translate that into R code?
> 
> Thanks in advance



See ?ifelse and ?Logic, both of which are covered in "An Introduction to R" (http://cran.r-project.org/manuals.html).

  MOC <- ifelse((otype == 'M') & (ocond == '1') & (entry == 'a.Prop'), 1, 0)


You might also want to think about getting a copy of:

R for SAS and SPSS Users
Robert Muenchen
http://www.amazon.com/SAS-SPSS-Users-Statistics-Computing/dp/0387094172

Regards,

Marc Schwartz