Help using Base SAS procedures

IF-Loop

Reply
N/A
Posts: 0

IF-Loop

Hi, I use the code below :
data revenue2;
set CAT_SORT;
if Good = "A" THEN
Margin = 10*Unit;
if Good = "B" AND
"01/01/2001"<=Date<="31/01/2001" THEN
Margin = 20*Unit;
IF Good = "B" AND
"01/02/2002"<=Date<="28/02/2002" THEN
Margin = 30*Unit;
RUN;


Is there a change that you could sugeest so that I use the IF twice only, that is, use Good="B" only once.

Kind Regards,
Mar
Valued Guide
Posts: 2,175

Re: IF-Loop

> Hi, I use the code below :
> data revenue2;
> set CAT_SORT;
> if Good = "A" THEN
> Margin = 10*Unit;
> if Good = "B" AND
> "01/01/2001"<=Date<="31/01/2001" THEN
> Margin = 20*Unit;
> IF Good = "B" AND
> "01/02/2002"<=Date<="28/02/2002" THEN
> Margin = 30*Unit;
> RUN;
>
>
> Is there a change that you could sugeest so that I
> use the IF twice only, that is, use Good="B" only
> once.
>
> Kind Regards,
> Mar

MarkC
you need to rephrase your message as it is not appearing correctly because of special symbols like <= avoid using < or <= by using LT or LE in syntax you post

Message was edited by: Peter.C
Super Contributor
Super Contributor
Posts: 3,174

Re: IF-Loop

Another option is to bookmark this link for future reference on forum posting guidelines with special-character content.

Also, for MarkC (and other posters) -- think before you post, particularly when selecting a forum, rather than simply choosing the first one in the list -- honestly, you're not the only individual doing this but it's a gentle suggestion.

Scott Barry
SBBWorks, Inc.

Thread: [Off-topic] Forum Markup
http://support.sas.com/forums/thread.jspa?messageID=27609
Ask a Question
Discussion stats
  • 2 replies
  • 119 views
  • 0 likes
  • 3 in conversation