how to display housing(H) and vehicle loan(V) of a customer who had taken in the same year?
table is like that
data cust_loan;
input accno loanno $ year loan_amount;
cards;
110010 H023 2006 400000
110126 H024 2006 410000
110278 H045 2006 420000
112345 H046 2007 430000
110345 H056 2007 440000
110023 V001 2006 45000
110126 V002 2006 60000
110126 V002 2007 60000
110345 V052 2007 60400
110127 V512 2007 60078
;
I have got result for cust who had taken both housing and vehicle loan but unable to get the result in the same year. plz check
proc sql;
select * from cust_loan where loanno like 'H%' and accno in (select accno from cust_loan
where loanno like 'V%')
UNION ALL
select * from cust_loan where loanno like 'V%' and accno in(select accno from cust_loan
where loanno like 'H%');
quit;
This is a possible solution:
[pre]
proc SQL;
create table r as select *
from cust_loan
group by year,accno
having count(*) > 1
order by year,accno
;quit;
[/pre]
Sincerely,
SPR
Ready to join fellow brilliant minds for the SAS Hackathon?
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.