create a variable

Accepted Solution Solved
Reply
Contributor
Posts: 22
Accepted Solution

create a variable

Hi ,

I have a dataset which looks like below 

 

MarketPricesname
2123sales
2salessales
3456

3

 

 

and I am trying to convert the excel formula  =IF(B2="sales",A2,IF(sname="sales",B2,C2) into sas .  which creates BC coloumn . Can anyone pls help 

 

MarketPricesnameBC
2123sales#NAME?
2salessales2
34563#NAME?

Accepted Solutions
Solution
‎06-16-2016 01:55 PM
Esteemed Advisor
Esteemed Advisor
Posts: 7,203

Re: create a variable

Your Excel formula doesn't work - as shown by the #name.

 

However you can break the logic out from the formula as:

data want;  
  set have;
  if price="sales" then bc=market;
  else do;
    if same="sales" then bc=price;
    else bc=sname;
  end;
run;

View solution in original post


All Replies
Solution
‎06-16-2016 01:55 PM
Esteemed Advisor
Esteemed Advisor
Posts: 7,203

Re: create a variable

Your Excel formula doesn't work - as shown by the #name.

 

However you can break the logic out from the formula as:

data want;  
  set have;
  if price="sales" then bc=market;
  else do;
    if same="sales" then bc=price;
    else bc=sname;
  end;
run;
Contributor
Posts: 22

Re: create a variable

Thank a lot 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 218 views
  • 0 likes
  • 2 in conversation