## Simple "new variable" question (beginner)

Solved
Occasional Contributor
Posts: 10

# Simple "new variable" question (beginner)

Hello,

I'm trying to create a new "running" variable in my data set but I cant figure out how to do it with a simple code. This is my dataset:

 Trial Interval Group Response New Variable 1 1 1 3 23 = 3 + 8 + 12 1 1 2 8 23 = 3 + 8 + 12 1 1 3 12 23 = 3 + 8 + 12 1 2 1 3 28 = 7 + 18 + 3 1 2 2 7 28 = 7 + 18 + 3 1 2 3 18 28 = 7 + 18 + 3 1 3 1 3 . . 1 3 2 17 . . 1 3 3 12 . . 1 4 1 19 1 4 2 15 1 4 3 16 2 1 1 0 2 1 2 11 2 1 3 17 2 2 1 7 2 2 2 20 2 2 3 10 2 3 1 0

The "new variable" should be created by adding up the three response values across all 3 group members for each interval but I would like to keep the sum as a variable (as shown).

Any help would be greatly appreciated.

Thank you.

Accepted Solutions
Solution
‎11-30-2013 11:07 PM
Occasional Contributor
Posts: 10

## Re: Simple "new variable" question (beginner)

Thank you. Your advice really helped. I managed to create the variable.

All Replies
Super User
Posts: 5,700

## Re: Simple "new variable" question (beginner)

Use SQL with group by on trial, interval and group, sum(response). If you want to keep the data on the detail level just keep response as seprate item in the select clause. SQL will automatically remerge back the sum on the detail rows.

Data never sleeps
Solution
‎11-30-2013 11:07 PM
Occasional Contributor
Posts: 10

## Re: Simple "new variable" question (beginner)

Thank you. Your advice really helped. I managed to create the variable.

🔒 This topic is solved and locked.