BookmarkSubscribeRSS Feed
NAVEENKUMAR
Calcite | Level 5

Hi I have  credit card approve/decline tables with one table contains last 8months data, so i have an other table of this month who has appiled for credit card,so what is my requirement is i wanna check weather the customer has already have a card r not ,if he is having i wanna decline tht customer to approve new credit card,so what i want to do is i wanna check latest table (i.e this month table where customer applied for new credit card ,assume tht it contain 10 thousand custumer records) ,to last 8months table(assume tht it contain 1millon customer records),here i enclosing some sample table for example

/*assume tht its  last 8months table which have 1million records*/

data table1;

input custid name$  salary pan$ aprvdate ;

informat aprv anydtdte.;

format aprv ddmmyy10.;

cards;

001 john 200000 AAAAAA 02/02/2014

002 raju 300000  BBBBBB 01/01/2013

002 raju 400002  BBBBBB 01/01/2014

003 david 600000  CCCCCC 04/04/2013

004 krishna 203030  DDDDDD 05/02/2015

005 mukesh 240000  EEEEEE 04/03/2014

003 david 782226  CCCCCC 08/05/2014

;

run;

/*assume that it contains current table whose wanna apply for new credit cards which contain 10thousand records*/

data table2;

input custid name$ salary pan$ aprv :anydtdte.;

format aprv ddmmyy10.;

cards;

002 raju 400000  BBBBBB 12/05/2015

005 mukesh 240000  EEEEEE 12/05/2015

003 david 782226  CCCCCC 01/7/2015

run;

Note :in table one the custmer raju and david had taken 2 cards ,they were already approved ,and check sal and date of approve ,for eg:raju taken cards on 01/01/2013 when his sal was 300000 again he applied for cards in 01/01/2014,again this card was approved and his sal aslo incresed,but in 12/05/2015 again he is applying for new credit cards,so i wanna check with previous table will this guy had already card/not,based on tht i wanna decline this card,and i wanna show my client reason why i m decline,i wanna result should be like this

002 raju 300000  BBBBBB 01/01/2015

002 raju 400002  BBBBBB 01/01/2015

002 raju 400000  BBBBBB 12/05/2015

so this i can show my client where he taken has taken card on 01/01/2013,again by mistakely we approved his card when he applied in 2014,so again this time he is applying for new card on 2015 ,so i gonna decline his application,even mukesh and david is already had card again he is applying in 2015 so i wanna decline him,

i wanna output like his

002 raju 300000  BBBBBB 01/01/2015

002 raju 400002  BBBBBB 01/01/2015

002 raju 400000  BBBBBB 12/05/2015

003 david 600000  CCCCCC 04/04/2013

003 david 782226  CCCCCC 08/05/2014

003 david 782226  CCCCCC 01/7/2015

005 mukesh 240000  EEEEEE 04/03/2014

005 mukesh 240000  EEEEEE 12/05/2015

so i wanna get output like this based on tht i can show my client these were the customer who had already got cards again they were applying,

Assume u have to compare 10thousand records with 1 milon records of previoud month,and pan number will be unique so based on tht we can catch up,

so plz write a code to resolve this kind of issue

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Duplicate of:

Ksharp
Super User

data table1;

input custid name $  salary pan $ aprv ;

informat aprv anydtdte.;

format aprv ddmmyy10.;

cards;

001 john 200000 AAAAAA 02/02/2014

002 raju 300000  BBBBBB 01/01/2013

002 raju 400002  BBBBBB 01/01/2014

003 david 600000  CCCCCC 04/04/2013

004 krishna 203030  DDDDDD 05/02/2015

005 mukesh 240000  EEEEEE 04/03/2014

003 david 782226  CCCCCC 08/05/2014

;

run;

data table2;

input custid name$ salary pan$ aprv :anydtdte.;

format aprv ddmmyy10.;

cards;

002 raju 400000  BBBBBB 12/05/2015

005 mukesh 240000  EEEEEE 12/05/2015

003 david 782226  CCCCCC 01/7/2015

;

run;

data want;

if _n_ eq 1 then do;

  if 0 then set table2;

  declare hash h(dataset:'table2');

  h.definekey('custid');

  h.definedone();

end;

set table1;

if h.check()=0;

run;

proc append base=want data=table2 force;run;

proc sort data=want;by custid;run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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