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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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