BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jcabrera
Calcite | Level 5

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.

1 ACCEPTED SOLUTION

Accepted Solutions
jcabrera
Calcite | Level 5

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

View solution in original post

2 REPLIES 2
LinusH
Tourmaline | Level 20

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
jcabrera
Calcite | Level 5

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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

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