Hi,

I am trying to control for the CBSA (a statistical area) in my dataset. To do this I think I would have to make a dummy variable which equals 1 if a firm (in my dataset) is in the statistical area. I have another dataset with all the postal codes listed but I do not know how I can match them into my master dataset and create this dummy variable. This is what the dataset with the list looks like:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str5 Postal_Code_CBSA
"01346"
"04546"
"02753"
"05948"
"25348"
"44148"
"12340"
"09126"
"00372"
"00572"
"01172"
"07172"
"08172"
"09972"
"11772"
"13172"
"14172"
"13339"
"15339"
"03535"
"09513"
"17713"
"27313"
"32113"
"04341"
"00136"
"08336"
"09136"
"09336"
"09536"
"16737"
"04727"
"09501"
"00135"
"04335"
"05735"
"06135"
"03701"
"12301"
"04322"
"07922"
"04127"
"13148"
"24948"
"04134"
"02542"
"07742"
"09542"
"05726"
"00726"
"01342"
"06540"
"01148"
"06548"
"35948"
"37548"
"38148"
"24913"
"26113"
"01519"
"16919"
"05736"
"02002"
"17002"
"00348"
"15118"
"16126"
"01501"
"01555"
"08755"
"02712"
"01940"
"08540"
"01372"
"02772"
"06572"
"11572"
"01905"
"02137"
"08737"
"08937"
"11537"
"00539"
"00739"
"00741"
"00520"
"00939"
"10747"
"21348"
"05913"
"19513"
"21913"
"22113"
"01313"
"01513"
"03513"
"04513"
"05713"
"06313"
"06713"
end
This is how my other dataset looks like:
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double fyear str20 addzip str10 cik
2009 "60191"      "0000001750"
2010 "60191"      "0000001750"
2011 "60191"      "0000001750"
2012 "60191"      "0000001750"
2013 "60191"      "0000001750"
2014 "60191"      "0000001750"
2015 "60191"      "0000001750"
2016 "60191"      "0000001750"
2017 "60191"      "0000001750"
2018 "60191"      "0000001750"
2010 "76155"      "0000006201"
2011 "76155"      "0000006201"
2012 "76155"      "0000006201"
2013 "76155"      "0000006201"
2014 "76155"      "0000006201"
2015 "76155"      "0000006201"
2016 "76155"      "0000006201"
2017 "76155"      "0000006201"
2018 "76155"      "0000006201"
2019 "76155"      "0000006201"
2010 "75254"      "0000003197"
2011 "75254"      "0000003197"
2012 "75254"      "0000003197"
2013 "75254"      "0000003197"
2014 "75254"      "0000003197"
2015 "75254"      "0000003197"
2016 "75254"      "0000003197"
2017 "75254"      "0000003197"
2018 "75254"      "0000003197"
2019 "75254"      "0000003197"
2010 "94402"      "0001230869"
2010 "94402"      "0001230869"
2011 "94402"      "0001230869"
2011 "94402"      "0001230869"
2012 "94402"      "0001230869"
2012 "94402"      "0001230869"
2013 "94402"      "0001230869"
2013 "94402"      "0001230869"
2014 "94402"      "0001230869"
2014 "94402"      "0001230869"
2015 "94402"      "0001230869"
2015 "94402"      "0001230869"
2016 "94402"      "0001230869"
2016 "94402"      "0001230869"
2017 "94402"      "0001230869"
2017 "94402"      "0001230869"
2018 "94402"      "0001230869"
2018 "94402"      "0001230869"
2019 "94402"      "0001230869"
2019 "94402"      "0001230869"
2010 "85072-3999" "0000764622"
2011 "85072-3999" "0000764622"
2012 "85072-3999" "0000764622"
2013 "85072-3999" "0000764622"
2014 "85072-3999" "0000764622"
2015 "85072-3999" "0000764622"
2016 "85072-3999" "0000764622"
2017 "85072-3999" "0000764622"
2018 "85072-3999" "0000764622"
2019 "85072-3999" "0000764622"
2010 "30339-3182" "0000706688"
2011 "30339-3182" "0000706688"
2012 "30339-3182" "0000706688"
2013 "30339-3182" "0000706688"
2014 "30339-3182" "0000706688"
2015 "30339-3182" "0000706688"
2016 "30339-3182" "0000706688"
2017 "30339-3182" "0000706688"
2018 "30339-3182" "0000706688"
2019 "30339-3182" "0000706688"
2010 "60064"      "0000001800"
2011 "60064"      "0000001800"
2012 "60064"      "0000001800"
2013 "60064"      "0000001800"
2014 "60064"      "0000001800"
2015 "60064"      "0000001800"
2016 "60064"      "0000001800"
2017 "60064"      "0000001800"
2018 "60064"      "0000001800"
2019 "60064"      "0000001800"
2010 "02445"      "0000001961"
2011 "02445"      "0000001961"
2012 "02445"      "0000001961"
2013 "02445"      "0000001961"
2014 "02445"      "0000001961"
2015 "02445"      "0000001961"
2016 "02445"      "0000001961"
2017 "02445"      "0000001961"
2018 "02445"      "0000001961"
2019 "02445"      "0000001961"
2010 "11050"      "0000002034"
2011 "11050"      "0000002034"
2012 "11050"      "0000002034"
2013 "11050"      "0000002034"
2014 "11050"      "0000002034"
2015 "11050"      "0000002034"
2016 "11050"      "0000002034"
2017 "11050"      "0000002034"
2018 "11050"      "0000002034"
2010 "06032"      "0000002062"
end
Kind regards,
Sarah