Announcement

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

  • Merge

    I should be able to figure thid out but it isd not working. I want to merge two files,

    The first is

    . use "D:\Data\dataadd1920.dta"

    . des *,full

    storage display value
    variable name type format label variable label
    -----------------------------------------------------------------------------------------------------------
    stateab double %8.0g state
    knownothingvote1856
    float %9.0g
    mexpop1910_01 double %6.4f
    state long %14.0g state State
    WHT_1910 double %12.0g 1910: % white population (Haines and ICPSR 2010)
    BLAC_1910 double %12.0g 1910: % black population (Haines and ICPSR 2010)
    RUR_1910 double %12.0g 1910: % rural population (Haines and ICPSR 2010)
    URB_1910 double %12.0g 1910: % urban population (Haines and ICPSR 2010)
    ENG_1910 double %12.0g 1910: % of whites born in England (Haines and ICPSR 2010)
    GERM_1910 double %12.0g 1910: % born in Germany (Haines and ICPSR 2010)
    IRE_1910 double %12.0g 1910: % born in Ireland (Haines and ICPSR 2010)
    ITAL_1910 double %12.0g 1910: % born in Italy (Haines and ICPSR 2010)
    CATHPER_1916 double %12.0g 1916: % of total adherents that are Roman Catholic (Finke and
    Stark 1986)
    ILLT_1920 double %12.0g 1920: % illiterate population, ages 10+ (Haines and ICPSR
    2010)
    ALC_1922 double %12.0g 1922: Alcoholism hospital admissions per 100,000 (America
    1920-1980)
    vollstead float %8.0g (mean) vote

    .





    The second is C:\Users\Emu\Downloads\Immigration1860state (4).dta :

    . fsum

    Variable | N Mean SD Min Max
    ----------+---------------------------------------------
    stateab | 37 19.00 10.82 1.00 37.00
    vote | 35 0.63 0.39 0.00 1.00
    party | 37 0.84 0.31 0.00 1.00

    I typed:

    merge 1:1 stateab using(D:\Data\dataadd1920.dta), saving(Immigration1860staterevise.dta) and received the message:
    invalid 'D'
    r(198)
    What did I do wrong?

    stateb is in both data sets so a marge should work.
    Any help would be appreciated.

    Ric Uslaner








  • #2
    the help file seems clear that you do NOT put the filename for the using data in parens - why do you think you should? see
    Code:
    help merge
    also, after this many posts, you should know about and be posting within CODE blocks which would make what you post much easier to read; maybe you should read (re-read?) the FAQ

    Comment


    • #3
      Rich Goldstein gives good advice, which is quite standard. Please present code readably. A simple experiment supports his guess.

      Code:
      . sysuse auto, clear
      (1978 automobile data)
      
      . keep mpg make
      
      . save d:\whatever
      file d:\whatever.dta saved
      
      . sysuse auto
      (1978 automobile data)
      
      . merge 1:1 make using(D:\whatever)
      invalid 'D' 
      r(198);
      
      . merge 1:1 make using D:\whatever
      
          Result                      Number of obs
          -----------------------------------------
          Not matched                             0
          Matched                                74  (_merge==3)
          -----------------------------------------
      merge is thrown by your use of parentheses. Whether the merge will work otherwise we can't tell from the rest of the evidence. For merge to work the two files should be of the same size and each with (presumably) 37 observations, so it would have been feasible to give a reproducible example using a subset of the variables and using dataex.

      Comment

      Working...
      X