Wasim raja
Wasim raja

Reputation: 13

How to create a new variable in SAS by extracting part of the value of an existing numeric variable with a condition from a catagorical variable?

I want to create a new variable called Sales_of_win7 I have two variables one is Total sale (Numeric variable)and another one is ProductGRpID which is a catagorical variable which contains(Two catagories: Win7 and Printers). So I want to create a variable Sales_of_win7 by extracting value from Total Sale if it only win7 in ProductGRpID. How can I do that?. Your help is appreciated.

Upvotes: 0

Views: 107

Answers (1)

Peter Flom
Peter Flom

Reputation: 2388

data new;
 set old;
 if ProductGRpID = "Win7" then sales_of_win7 = total_sale;
run;

You could add an "else" statement if you want something specific to happen in other cases

Upvotes: 0

Related Questions