BookmarkSubscribeRSS Feed
kazimir900
Calcite | Level 5

Hey Guys,

 

i have the following problem. I have a table like this:

 

Contract ID       Company    Account-Action      Amount

A12345             XXXXX       Provision               30,00

A12345             XXXXX       Outstanding          450,00

B12345             YYYYY       .....

 

Now I'd like to transpose this table to:

 

Contract ID       Company    Provision     Outstanding

A12345             XXXXX       30,00               450,00

B12345             YYYYY       .....

 

Thanks a lot for yout help!!!

 

Lars

 

2 REPLIES 2
novinosrin
Tourmaline | Level 20
data have;
input (ContractID       Company    Account_Action      Amount) (:$20.);
cards;
A12345             XXXXX       Provision               30,00
A12345             XXXXX       Outstanding          450,00
;

proc transpose data=have out=want(drop=_name_);
by ContractID       Company ;
id Account_Action;
var amount;
run;
r_behata
Barite | Level 11
data have;
	input (ContractID       Company    Account_Action      Amount) (:$20.);
	infile cards truncover;
	cards;
A12345             XXXXX       Provision               30,00
A12345             XXXXX       Outstanding          450,00
B12345             YYYYY
;
run;

data want;
	set have;
	by ContractID;
	retain Provision Outstanding;
	format Provision Outstanding comma8.2;
	array var[*] 8 Provision Outstanding;
	i=1;

	if first.ContractID then
		do;
			call missing(Provision,Outstanding);
			var[i]=input(Amount,comma8.2);
		end;
	else
		do;
			i+1;
			var[i]=input(Amount,comma8.2);
		end;

			if last.ContractID ;
		keep ContractID Company Provision Outstanding;
run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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