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? 

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!

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