Hello,
My data looks like this
I want to write a command that will write a new column and score of 1 if the company take a loan previously using the date of the loan and score 0 if they didn't before and
like for example the first company is sony took a loan from a bank ID 10 in 2001 the result is 1 because sony did take a loan before 2001 Previously which is in 1999.
the table supposed to look like this
My data looks like this
Code:
clear input byte(Loan_ID Bank_ID) str7 Company int Dateoftheloan 1 10 "sony" 2001 2 4 "sony" 1999 3 10 "logi" 2000 4 2 "toshiba" 2010 5 9 "ford" 2020 6 20 "ford" 2010 7 15 "apple" 2015 8 2 "apple" 2014 9 4 "samsung" 2009 10 5 "samsung" 2002 end
like for example the first company is sony took a loan from a bank ID 10 in 2001 the result is 1 because sony did take a loan before 2001 Previously which is in 1999.
the table supposed to look like this
Code:
* clear input byte(Loan_ID Bank_ID) str7 Company int Dateoftheloan byte result 1 10 "sony" 2001 1 2 4 "sony" 1999 0 3 10 "logi" 2000 0 4 2 "toshiba" 2010 0 5 9 "ford" 2020 1 6 20 "ford" 2010 0 7 15 "apple" 2015 1 8 2 "apple" 2014 0 9 4 "samsung" 2009 1 10 5 "samsung" 2002 0 end
Comment