Announcement

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

  • HELP regarding merging two files (HCUP databases)

    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


  • #2
    Some suggestions:
    • Are there duplicates in hosp_nr even before the type is changed? Use the -duplicates- command rather than trusting the documentation.
    • Can you use the -duplicates- command to look at a couple of recast examples to see what is being lost?

    Comment


    • #3
      Cross-posted at https://www.reddit.com/r/stata/comme..._hcup_dataset/

      Please note that it's a request here and a rule on Reddit to tell people about cross-posting.

      Comment


      • #4
        updated Reddit post with link for cross posting and thanks for updating with cross posting reddit link here. Thanks . I wasn't aware of this rule.

        Comment

        Working...
        X