BookmarkSubscribeRSS Feed
Aexor
Lapis Lazuli | Level 10

Hi,

 

I have this table 

data example;
input account_Nbr rate_StartDate date9. typecode rate_id Amount;
format rate_StartDate date9.;
Cards;
130 06Jan1999 10 10062 1700.9600
130 01Jan1990 10 10063 17766.9800
130 29Jul2005 11 14414 51.5900
130 01Jan1990 11 10063 998.5000
130 06Jan1999 11 10062 160.5300
130 02Apr2013 11 76522 0.0900
130 01May2003 11 10526 22.1700
130 01Jul2000 11 10061 249.9610

 

In output table i need to get only 2 columns

condition
when there is a typecode ="10", take typecode = "11" that have the same Rate_ID and calculate total amount

This means
column 1 will have sum of total amount when rate_id is same i.e 1062 for typecode = 10 and typecode = 11
column 2 will have sum of total amount when rate_id is same i.e 1063 for typecode = 10 and typecode = 11

Please help.

1 REPLY 1
tarheel13
Rhodochrosite | Level 12
proc sql;
	create table totals as select rate_id, sum(amount) as total
		from example
		where rate_id in (10062, 10063)
		group by rate_id;
quit;

proc transpose data=totals out=totals_t;
	id rate_id;
	var total;
run;

Does this get what you want? 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 1 reply
  • 571 views
  • 0 likes
  • 2 in conversation