Hi,

I am currently doing my thesis and I am struggling with this problem.

I have a panel dataset in which law (dummy variable) is the identification between treatment group and control group. I want to do a matching with replacement based on size and SIC code. Specifically, I want to match by firm size in a range of 50%, in the same 2-digit SIC industry and same year. If there is no proper match in the same 2-digit industry, I want to match it with the one the same 1-digit industry

This is an example of my dataset.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long gvkey int fyear str1 sic1 str2 sic2 double at byte law
12622 1992 "3" "38"   100.19 0
12622 1993 "3" "38"   89.988 0
12622 1994 "3" "38"   89.778 0
14453 1992 "7" "73"    9.335 0
14453 1993 "7" "73"   14.157 1
14453 1994 "7" "73"   25.009 0
14453 1995 "7" "73"   46.685 0
14453 1996 "7" "73"   86.294 0
11907 1992 "3" "36"    5.833 1
11907 1993 "3" "36"   11.169 0
11907 1994 "3" "36"     9.79 0
11907 1995 "3" "36"   17.668 0
11907 1996 "3" "36"   13.482 1
11907 1997 "3" "36"    12.24 0
11907 1998 "3" "36"   10.279 0
11907 1999 "3" "36"   14.124 0
 4641 1992 "3" "38" 1113.055 0
 4641 1993 "3" "38"  998.403 0
 4641 1994 "3" "38"  644.464 0
 4641 1995 "3" "38"  367.479 0
end
Which codes should I use to solve this problem?

I really appreciate if you could help me.

Thank you.