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

Hi All, 

 

I have to figure out how to do a cumulative sum of all variables by row. Proc Means will sum each variable (column) but for all rows. I need to sum all columns (variables) by row. 


I understand how to use BY or CLASS to group my output, but how do I sum all variables? I have a preset dataset, and I need to read from that and create a dataset that sums all variables. 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
5 REPLIES 5
Reeza
Super User
Please show a fully worked example with say 5 to 10 rows and 5 variables.
PaigeMiller
Diamond | Level 26

Can you create a small example and show us what you want?

 

I think that the wording you used "how to do a cumulative sum of all variables by row" can be interpreted in two ways

--
Paige Miller
Julia10
Fluorite | Level 6

Sure, ok. 

 

I have a survey by participant (100 participants) which are my observation data (rows). Each survey has 20 questions. 

 

I have some participant background info and 20 survey questions q1-q20. I need to add all the numbers that each participant gave for each question to create a score. If I were using excel, it would be SUM(B2:U2), with the next column storing the resulting total. 

 

Does this help? 

 

The format is basically: 

ParticipantID    Q1  Q2   Q3   Q4

1                       2     3      4      2

2                       1     1      2      1   

 

The totals I need are by adding all question data per participant, or by row. Hence, participant 1 total would = 11 and participant 2 would = 5 . 

 

 

Reeza
Super User
TOTAL_SCORE = sum(of Q1-Q4);

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1458 views
  • 3 likes
  • 3 in conversation