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

Art

Really?

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!

Ksharp

MarkGIP
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.

art297
Opal | Level 21

Mark,

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!

MarkGIP
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?

art297
Opal | Level 21

Mark,

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);

k=0;

/*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;

      y(j+1)=a(i+j);

    end;

/*calculate the desired sum*/

    k+1;

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

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

  end;

run;

MarkGIP
Calcite | Level 5

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

sas-innovate-2024.png

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
  • 3442 views
  • 7 likes
  • 5 in conversation