Announcement

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

  • String type mismatch error in frameappend

    Hi,

    I am trying to append dataframes, and some of the variables are in diferent formats in different datasets. Its little difficult to cross-check which ones are different as there are too many variables, so I am wondering if there is any method to force the append despite the type mismatch.

    Code:
    . frameappend df1 df2 df3
    namelist:  too many specified
    r(103);
    
    . frame dir
    * default  1503 x 14162; hh_endline.dta
    * df1      1387 x 7503; hh_baseline.dta
    * df2      1359 x 8193; hh_midline.dta
    * df3      1503 x 14162; hh_endline.dta
    
    Note: frames marked with * contain unsaved data
    
    
    . frameappend df2
    shared variables in frames being combined must be both numeric or both string
    type mismatch
    r(109);
    Please let me know.
    Thanks in advance.

  • #2
    Originally posted by Sonnen Blume View Post
    ]so I am wondering if there is any method to force the append despite the type mismatch
    No, you have to sort this out before appending.

    Comment


    • #3
      If you use Stata's append command, it has a -force- option. So here's what you could do:

      Code:
      tempfile holding
      frame change default
      forval i=1/3{
          frame df`i': save `holding', replace
          append using `holding', force
      }
      But this may not help because the mismatched variables will contain missing values in observations corresponding to the appended dataset as described in the documentation:

      force allows string variables to be appended to numeric variables and vice versa, resulting in missing values from the using dataset. If omitted, append issues an error message; if specified, append issues a warning message.

      So that takes you back to #2.
      Last edited by Andrew Musau; 30 Mar 2025, 10:43.

      Comment


      • #4
        Its little difficult to cross-check which ones are different as there are too many variables,...
        Mark Chatfield's -precombine-, available from SSC, will make this much easier for you.

        Comment

        Working...
        X