I'm trying to find a more efficient way to tell SAS to look at an observation and count the number of "successes" when looking at specific variables and then to create a new variable that is the count of "successes" for this observation.

OBS X1 X2 X3

1 1 0 0

2 1 1 1

.

.

.

n 0 1 0

I want the syntax to tell SAS to look in each row and only count the 1's for X1 and X3 while ignoring X2. I want the sum of the 1's to enter into a new variable, X4.

For example, OBS 1 X4=1, OBS2 X4=2, OBS3 X4=0.

I have been using just:

IF X1 =1 THEN X4=1;

IF X3=1 THEN X4=X4+1;

I currently have some that are in Y/N format, and I'd like to improve my skills with this. The easier solution I see is to recode Y/N as 1/0 numeric then just SUM (X1,X3) to arrive at X4.

Looking forward to some other ideas that are surely better principled and more efficient.