data a;
input x y z;
datalines;
1 2 3
4 5 .
6 . .
;
proc means sum;
run;
have:
x = 11, y = 7, x = 3
want:
x = 11, y = ., x = .
is it possible to enforce this behaviour?
I would use a data step:
data want;
set have;
retain sum_x sum_y sum_z 0;
sum_x = sum_x + x;
sum_y = sum_y + y;
sum_z = sum_z + z;
drop x y z;
run;
I assume by "bigger" you mean that you have a lot more variables.
If so, you can use an array
data want;
set have;
array x(*) var1-var200;
array sum(*) sum1-sum200 (200*0);
do i=1 to dim(x);
sum(i)=sum(i)+x(i);
end;
drop i;
run;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.