I am trying to merge two files (Core and cost to ratio files ,M:1 merge) using variable hosp_nrd. In the Core file, hosp_nrd is stored as long but in cost to ratio files hosp_nrd is stored as string to preserve leading zeros. If i change hosp_nrd variable to numeric in cost to charge ratio file, then I am get many surplus values for hosp_nrd. Shall I change hosp_nrd to string in core file? What is the solution. ?Please guide. This link provides information about cost to charge ration file: IPCCR_UserGuide_2012-2019. this link provides info about core file (NRD File Specifications)
If I don't change variable, then I get this message:
"key variable hosp_nrd is long in master but str7 in using data
Each key variable (on which observations are matched) must be of the same generic type in the master and using datasets. Same generic type
means both numeric or both string.
r(106);"
If I change the hosp_nrd variable to numeric in cost to charge ratio file then I get this error message:
"variable hosp_nrd does not uniquely identify observations in the using data
r(459);"
If I change hosp_nrd to string in Core file and then try to merge with cost to charge ratio file. I get these results. none fo the results match
"merge m:1 hosp_nrd using "D:\NRD\2020 NRD\CC2020originalsaved.dta"
Result Number of obs
-----------------------------------------
Not matched 16,695,233
from master 16,692,694 (_merge==1)
from using 2,539 (_merge==2)
Matched 0 (_merge==3)"
Please guide me on the right approach to merge these files
If I don't change variable, then I get this message:
"key variable hosp_nrd is long in master but str7 in using data
Each key variable (on which observations are matched) must be of the same generic type in the master and using datasets. Same generic type
means both numeric or both string.
r(106);"
If I change the hosp_nrd variable to numeric in cost to charge ratio file then I get this error message:
"variable hosp_nrd does not uniquely identify observations in the using data
r(459);"
If I change hosp_nrd to string in Core file and then try to merge with cost to charge ratio file. I get these results. none fo the results match
"merge m:1 hosp_nrd using "D:\NRD\2020 NRD\CC2020originalsaved.dta"
Result Number of obs
-----------------------------------------
Not matched 16,695,233
from master 16,692,694 (_merge==1)
from using 2,539 (_merge==2)
Matched 0 (_merge==3)"
Please guide me on the right approach to merge these files
Comment