SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Simple "new variable" question (beginner)

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 10
Accepted Solution

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:

TrialIntervalGroupResponseNew Variable
111323= 3 + 8 + 12
112823= 3 + 8 + 12
1131223= 3 + 8 + 12
121328= 7 + 18 + 3
122728= 7 + 18 + 3
1231828= 7 + 18 + 3
1313..
13217..
13312..
14119
14215
14316
2110
21211
21317
2217
22220
22310
2310

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.

View solution in original post


All Replies
Super User
Posts: 5,438

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.

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

Discussion stats
  • 2 replies
  • 278 views
  • 3 likes
  • 2 in conversation