BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Super User



I do not know to say what. Maybe Op should post some sample data and output he want to illustrate what exactly he want.

BTW. You still did not go to sleep? Respect!


Calcite | Level 5

Thank you all for your assistance!

@Ksharp: Since I'm not familiar with macro I cannot check wether your code does the same...

The problem with Art297's suggested code is that it does not seem to work when the variables have more then just one observation. Summing up the observations for each variable would not solve the problem cause I need them separated.

Opal | Level 21


When you say "when the variables have more than just one observation" do you mean "when there is more than just one record"?

My understanding is that you have 2 or more records, with each record having 5000 variables that you want to sum (within each record) for each set of 500 variables.

Obviously, I am misunderstanding something!

Calcite | Level 5

Sorry for confusing you...

When I'm speaking of observations I mean records.... And yes the number of records is greater than two. Maybe there has been a slight mixup....

Please excuse if I'm a bit slow in the mind. But using your code on the entire records leads to an error. Do I have to peform the code on every record separately?

Opal | Level 21


There was a line missing from my code.  k has to be initialized at the beginning of each record.  Try it with the following:

data want (drop=a: y:);

  set have;

/*  assign all 5000 variables to the array a*/

  array a(5000) a1-a5000;

/*initialize 2 additional arrays to represent x1 to*/

/*x50 .. the variables that will contain the sums and*/

/*y1 to y100 .. the variables that will temporarily*/

/*contain the values from each set of 100 variables*/

  array x(50);

  array y(100);


/*loop through the variables 100 at a time*/

  do i=1 to 4901 by 100;

/*fill the array y with each set of 100 variables*/

    do j=0 to 99;



/*calculate the desired sum*/


    x(k)=sum(of y:);

/*move onto the next set of 100 variables*/



Calcite | Level 5

Works like a charm.... Thank you so much!!!!


Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.


Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 20 replies
  • 5 in conversation