Except for SUM, SAS really lacks row functions. I wanted to count certain extended missing codes within waves of a longitudinal dataset.
I can use arrays to process over a hard coded varlist for each wave, but I had no luck making a macro that I could call for each wave. The problem seemed to be no way to pass in the varlist, especially if using first--last notation.
data xxx;
input a b c d e f;
datalines;
1 2 3 4 5 6
.w .w .w .w .w .w
3 4 5 .w .w .w
;
run;
data yyy(drop=i); set xxx;
array wave1vars(*) a--c;
wave1count = 0;
do i = 1 to dim(wave1vars);
if wave1vars(i) = .w then wave1count = wave1count +1;
end;
array wave2vars(*) d--f;
wave2count = 0;
do i = 1 to dim(wave2vars);
if wave2vars(i) = .w then wave2count = wave2count +1;
end;
run;