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

I want to collapse dollars by summing by a specific variable.  Every column in these two observations is the exact same except the PYMT_AMT_DLR.  I would like to get that load to add up together then i can can sum by TRIP later and eventually do a comparison. 

 

LD_LEG_IDTRIP_IDPYMNT_AMT_DLR
10790980349314144.00
10790981349314-24.04
10790981349314144.00

 

Any help would be appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

proc SQL is most flexible for this kind of task:

 

proc sql;
create table by_Ld_Leg as
select 
	TRIP_ID, 
	LD_LEG_ID,
	sum(PYMNT_AMT_DLR) as sum_by_leg
from myData
group by TRIP_ID, LD_LEG_ID;
/* Later ... */
create table byTrip as
select
	TRIP_ID,
	sum(sum_by_leg) as sum_by_trip
from by_Ld_Leg
group by TRIP_ID;
quit;
PG

View solution in original post

3 REPLIES 3
LinusH
Tourmaline | Level 20
Not sure what you want, a straight summary?
Can be done in tons of ways : SQL, PROC SUMMARY, even the data step...
Data never sleeps
PGStats
Opal | Level 21

proc SQL is most flexible for this kind of task:

 

proc sql;
create table by_Ld_Leg as
select 
	TRIP_ID, 
	LD_LEG_ID,
	sum(PYMNT_AMT_DLR) as sum_by_leg
from myData
group by TRIP_ID, LD_LEG_ID;
/* Later ... */
create table byTrip as
select
	TRIP_ID,
	sum(sum_by_leg) as sum_by_trip
from by_Ld_Leg
group by TRIP_ID;
quit;
PG
Raj21
Calcite | Level 5

This worked exactly the way that I wanted, thank you!

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 3 replies
  • 1619 views
  • 0 likes
  • 3 in conversation