BookmarkSubscribeRSS Feed
Quodly
Obsidian | Level 7
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?

3 REPLIES 3
Quodly
Obsidian | Level 7
as my actual dataset is much bigger than my example above, i was wondering if one can imitate the missing behaviour of the plus operator in proc means. using a simple data step with some form of loop over the variables is a good idea, though. thanks, kurt!
PaigeMiller
Diamond | Level 26

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;
--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1097 views
  • 3 likes
  • 3 in conversation