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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 923 views
  • 3 likes
  • 2 in conversation