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

Hello, i want to ask how can i sum each previous rows by variable SPCislo, here is sample of data:

 

PKDatumPodpisuSPcislocislo
50137732423320323Sep2019 0:00:00,000510054310
50137732423320823Sep2019 0:00:00,000510054310
50137732423321323Sep2019 0:00:00,000510054310
50137732427498123Sep2019 0:00:00,000510054310
50137732446151810Mar2020 0:00:00,00055538,0352
50137732445214811Mar2020 0:00:00,00055511,543
50137732445847112Mar2020 0:00:00,000555195,7242

 

And i want to calculated sum of each row by rows group by SPCislo, like this:

PKDatumPodpisuSPcislocislohow to calculate this???
50137732423320323Sep2019 0:00:00,00051005431010
50137732423320823Sep2019 0:00:00,00051005431020
50137732423321323Sep2019 0:00:00,00051005431030
50137732427498123Sep2019 0:00:00,00051005431040
50137732446151810Mar2020 0:00:00,00055538,035238,0352
50137732445214811Mar2020 0:00:00,00055511,54349,5782
50137732445847112Mar2020 0:00:00,000555195,7242245,3024

 

Thanks all for help 🙂

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20
data want;
   set have;
   by SPcislo;
   if first.SPcislo then c = 0;
   c + cislo;
run;

View solution in original post

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20
data want;
   set have;
   by SPcislo;
   if first.SPcislo then c = 0;
   c + cislo;
run;
Kurt_Bremser
Super User

Or, very slightly optimized:

data want;
set have;
by SPcislo;
if first.SPcislo
then c = cislo;
else c + cislo;
run;

(at all FIRST. events, there's only one assignment instead of two)

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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