BookmarkSubscribeRSS Feed
BaalaRaaji
Quartz | Level 8

Hi , below is the sample dataset.

datebucketbal
30-Sep-180                               10
30-Sep-181                               20
30-Sep-182                               30
30-Sep-183                               40
30-Sep-184                               50
30-Sep-185                               60
30-Sep-186                               70
30-Sep-187                               80
30-Sep-189                               90

 

I wanted to sum the values using SUM function..

if bucket in '(1,9) then balance else display the balance. like below

 

below table

 

30-Sep-180                               10  
30-Sep-181                               11020+90bucket 1& 9)
30-Sep-182                                 30  
30-Sep-183                                 40  
30-Sep-184                                 50  
30-Sep-185                                 60  
30-Sep-186                                 70  
30-Sep-187                                 80  
     
30+sum(of bucket >2)  
90+sum(of bucket >4)  

 

appreciate your help.thanks RS

5 REPLIES 5
Reeza
Super User
You want a multilabel format and you likely don’t want the sum function since that works on a row. You likely want a summary procedure such as PROC MEANS. If you really want the SUM() function that would be a data step operation then.

Here’s a fully worked example of a multilabel format and how it works
https://gist.github.com/statgeek/1c6f38ef368a4272cf458b017fc63d4b
Shmuel
Garnet | Level 18

Assuming your data contains more than one day dates - should summary be per day ?

 

What kind of output you want - data-set or listing ? 

 

Please post how should final output look like. 

 

What code did you try ?

novinosrin
Tourmaline | Level 20
easy and straight forward in sql, but before that what happended to 8 in bucket and why not display 20+90 in bucket 9 as well. I'll await your response
BaalaRaaji
Quartz | Level 8

Please ignore the query.I have figure out the solution in proc sql .thanks

appreciate everyone for quick replies.thank you

 

cheers!

LinusH
Tourmaline | Level 20
Then please share for other to learn!
Data never sleeps

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
  • 1301 views
  • 0 likes
  • 5 in conversation