DATA Step, Macro, Functions and more

Creating a sum of group variable that is same for all observ. in group

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 82
Accepted Solution

Creating a sum of group variable that is same for all observ. in group

    Lets say I have a value of 1 for each item in a group. Sometimes it adds to 13, somtimes to 7, etc. and then I want a  sum, which is the final value of each group. I know I can use last.variable for each group and then output to new dataset and then combine in sql easy enoug, but I want to avoid the extra step.

Basically:

GameValueCum. Sum
A11
A12
A13
A14
A15

I want the last cum. sum statement to be the last for each game (Game A would have 5 for each). Again, easy enough to do with last. and a join, but any easy way to simply do it all in one datastep?


Accepted Solutions
Solution
‎02-19-2013 07:00 PM
Super User
Posts: 19,770

Re: Creating a sum of group variable that is same for all observ. in group

Even if you do it in one datastep you're making more than one pass through the data.

If the one step is important, then look into a DOW loop.

View solution in original post


All Replies
Solution
‎02-19-2013 07:00 PM
Super User
Posts: 19,770

Re: Creating a sum of group variable that is same for all observ. in group

Even if you do it in one datastep you're making more than one pass through the data.

If the one step is important, then look into a DOW loop.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 143 views
  • 0 likes
  • 2 in conversation