Announcement

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

  • Merging two datasets

    Hello,

    I have to merge two datasets. The key variable is str32. The problem I'm facing is that in one of the data files, this key variable is like 'TUS10008106201911420902372MAN 01' and in another, it is like 'TUS10008106201911420902372MAN01'. Due to this, around 8,000 observations are not matching. Is there any way to remove the spaces in one go because doing it manually will consume a lot of time?

    Thanks.

  • #2
    You should have provided data example according to the forum rules. Since you didn't do it, here is a solution purely on what you have asked:

    Code:
    
    clear
    set obs 3
    
    g str10 var1=""
    replace var1="This is not what I want"
    li var1
    
         +-------------------------+
         |                    var1 |
         |-------------------------|
      1. | This is not what I want |
      2. | This is not what I want |
      3. | This is not what I want |
         +-------------------------+
    
    
    replace var1 = subinstr(var1," ","",.)
    li var1
    
    
         +--------------------+
         |               var1 |
         |--------------------|
      1. | ThisisnotwhatIwant |
      2. | ThisisnotwhatIwant |
      3. | ThisisnotwhatIwant |
         +--------------------+
    Roman

    Comment


    • #3
      Thank you, Roman. This solved my problem.

      Comment

      Working...
      X