Hi everyone,
I'm writing this function which helps to generate a one to one mapping of two identifiers by the help of their firm names' start and end dates.
cap prog drop create_unique_match
prog def create_unique_match
args unique_firm min_date_uniq max_date_uni count_firm min_date_c max_date_c
gen tag_date = 1 if (`min_date_uni' >= `min_date_c' & `min_date_uni' <= `max_date_c')
replace tag_date = 1 if (`max_date_uni'>=`min_date_c' & `max_date_uni'<=`max_date_c')
replace tag_date = 0 if mi(tag_date)
bys `unique_firm': egen flag_date = max(tag_date)
keep if tag_date==flag_date
bys `unique_firm': egen max_simi_score = max(simi_score)
keep if simi_score==max_simi_score
duplicates drop `unique_firm', force
end
and then I ran the following code:
create_unique_match assignee_id min_ee_name_dt max_ee_name_dt permco min_listed_dt max_listed_dt
Then it reports:
<=max_listed_dt invalid name
r(198);
But if I go back to my data without using the function but instead:
local min_date_uni min_ee_name_dt
local max_date_uni max_ee_name_dt
local min_date_c min_listed_dt
local max_date_c max_listed_dt
gen tag_date = 1 if (`min_date_uni' >= `min_date_c' & `min_date_uni' <= `max_date_c')
it doesn't report any error.
Could anybody help me with this? Many thanks!
Best,
Luman
I'm writing this function which helps to generate a one to one mapping of two identifiers by the help of their firm names' start and end dates.
cap prog drop create_unique_match
prog def create_unique_match
args unique_firm min_date_uniq max_date_uni count_firm min_date_c max_date_c
gen tag_date = 1 if (`min_date_uni' >= `min_date_c' & `min_date_uni' <= `max_date_c')
replace tag_date = 1 if (`max_date_uni'>=`min_date_c' & `max_date_uni'<=`max_date_c')
replace tag_date = 0 if mi(tag_date)
bys `unique_firm': egen flag_date = max(tag_date)
keep if tag_date==flag_date
bys `unique_firm': egen max_simi_score = max(simi_score)
keep if simi_score==max_simi_score
duplicates drop `unique_firm', force
end
and then I ran the following code:
create_unique_match assignee_id min_ee_name_dt max_ee_name_dt permco min_listed_dt max_listed_dt
Then it reports:
<=max_listed_dt invalid name
r(198);
But if I go back to my data without using the function but instead:
local min_date_uni min_ee_name_dt
local max_date_uni max_ee_name_dt
local min_date_c min_listed_dt
local max_date_c max_listed_dt
gen tag_date = 1 if (`min_date_uni' >= `min_date_c' & `min_date_uni' <= `max_date_c')
it doesn't report any error.
Could anybody help me with this? Many thanks!
Best,
Luman
Comment