Reputation: 1
This is the data set, what I want to do is to count how many Yes in each row, like the first row has 3 Yes so in my new column called Product_Held will have "3".
Upvotes: 0
Views: 333
Reputation: 1269773
In SQL, you can use:
proc sql;
select t.*,
( (case when bank_account = 'Yes' then 1 else 0 end) +
(case when credit_card = 'Yes' then 1 else 0 end) +
. . .
) as num_yeses
from t;
You can create a view using:
proc sql;
create view <viewname> as
select t.*,
( (case when bank_account = 'Yes' then 1 else 0 end) +
(case when credit_card = 'Yes' then 1 else 0 end) +
. . .
) as num_yeses
from t;
Upvotes: 0