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
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;
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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 save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.