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

 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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