Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Matching loan data with firms data

    Dear Stata community readers,
    I’m matching firms loan data with firms accounting data in an international sample and I need to match firms’ fiscal year ending accounting data priori to the firms’ loan issuance. For example, suppose firm A obtained a loan in 01/05/2022. I would like to write a code in stata to match firm A loan data with the closest fiscal year ( 11/10/2021) ending to show the true impact on loan spread. My merging code : merge 1:m using a country name , firms’ ticker. Help is greatly appreciated

  • #2
    why not create a mergeyear variable in both datasets and merge on that? mergeyear in the first dataset depends on the month (<=6 or whatever) and mergeyear in the second dataset is just mergeyear=year.

    Comment


    • #3
      Thanks George for your suggested solution. How would you write that as a code though ?

      Comment


      • #4
        A

        Comment


        • #5
          I'll spitball here since I'm not good with dates in Stata.

          For the financial data, say you have a variable year:

          Code:
          g mergeyear = year
          For the loan issuance data:
          Code:
          g year = year(date)
          g month = month(date)
          g mergeyear = (year-1)*(month<=6) + year*(month>6)




          Comment

          Working...
          X