Hi, Below attached file is the interview question which I faced,below is the code which I have developed for the same,let me know if that code is correct or any changes are required ,pld help me out regarding this. data test1; input CustomerId $1-5 DomicileCountryCode $7-9 IncorporationCountryCode $11-13 ParentCustomerId $15-20 CustomerType $23-27; cards; A1111 SG X1111 BANK B2222 HK X1111 BANK X1111 US US X2222 TW TW C3333 CN X2222 CORP ; run; data test2; input CustomerId $ ScoreCardId CustomerCreditGrade $ ScoreCardDate ScoreCardApprovedFlag $; informat ScoreCardDate ddmmyy10.; format ScoreCardDate ddmmyy10.; cards; X1111 32104 AA+ 31/12/2016 Y X1111 32105 AAA 31/03/2017 N X1111 32103 AA 30/6/2016 Y X1111 32102 AA- 31/03/2016 Y X2222 40321 BBB 31/12/2016 N X2222 40322 BBB+ 31/12/2016 Y ; run; proc sql; create table test3 as select CustomerId,ScoreCardId,CustomerCreditGrade,ScoreCardDate, ScoreCardApprovedFlag from test2 where ScoreCardApprovedFlag='Y' ; quit; proc sql; create table test4 as select CustomerId,ScoreCardId,CustomerCreditGrade,ScoreCardDate, ScoreCardApprovedFlag from test3 group by CustomerId having ScoreCardDate=max(ScoreCardDate) ; quit; proc sql; create table test5 as select b.* ,a.CustomerType from test1 a,test4 b where a.ParentCustomerId=b.CustomerId; quit; proc sql; create table test6 as select b.* ,a.IncorporationCountryCode from test1 a,test5 b where a.CustomerId=b.CustomerId; quit; proc sql; create table final as select distinct a.CustomerId,b.ScoreCardId,b.CustomerCreditGrade,a.DomicileCountryCode, b.IncorporationCountryCode,b.CustomerType from test1 a right join test6 b on a.ParentCustomerId=b.CustomerId or a.CustomerId=b.CustomerId group by b.CustomerCreditGrade ; quit;
... View more