Announcement

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

  • Issue with rangejoin

    Hello,

    I have the following data below:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long ID double(start end)
    1 233 247
    2 234 251
    3 235 236
    end
    format %tq start
    format %tq end
    
    tempfile file1
    save `file1'
    drop _all
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long ID double(time)
    1 239
    2 242
    3 236
    end
    format %tq time
    When I use the -rangejoin- command, I get the following error "was expecting a numeric variable, a number, or a system missing value for the interval low: start"
    Code:
    rangejoin time start end using `file1', by(ID)
    I would appreciate any assistance with this.

    Best,
    Anoush K.
    Last edited by Anoush Khachatryan; 09 Jan 2023, 12:03.

  • #2
    Yes, this is something that often confuses people trying to use -rangejoin-. You have the roles of the two files reversed. In the interval specified in -rangejoin- the first variable (time) must be a variable in the using file, and the other two must come from the file that is already in memory. You have it the other way around. So the correct sequence looks like this:
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long ID double(start end)
    1 233 247
    2 234 251
    3 235 236
    end
    format %tq start
    format %tq end
    
    tempfile file1
    save `file1'
    drop _all
    
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long ID double(time)
    1 239
    2 242
    3 236
    end
    format %tq time
    tempfile file2
    save `file2'
    
    use `file1'
    rangejoin time start end using `file2', by(ID)

    Comment


    • #3
      Clyde Schechter thank you so much! It worked perfectly!

      Comment

      Working...
      X