0

the code was ok, but in the second time is not working even though the variable is named differently[][Here is a picture of the error that I'm receiving]I'm working on bankscope database and there are some duplicates. Hence, I'm trying to overcome the duplication. I have tried this following code

foreach var of varlist address website phone fax {
        qui duplicates tag `var' year cntrycde ///
        if `var'~="", gen(dup_entry)
}

However, I kept receiving an error message which says

(invalid name) 
r(198)

Can you help to overcome this issue?

  • 1
    Data example please – Bicep Jun 30 '22 at 00:23
  • 2
    Second time around the loop, the `generate` will fail as `dup_entry` already exists. You need a new variable name every time you `generate` a new variable. – Nick Cox Jun 30 '22 at 00:53
  • Hello Nick, Thanks a lot for your help. I have tried your suggested solution. However, same error message still appears. I have used different name as well but not showing same issue still. I have attached two pictures to show how the message and picture to show same code with different use was working. Any further help would be grateful – Ammanna Azawi Jun 30 '22 at 16:56
  • Thanks Cybernike. I'm working with bankscope data which is kind of lengthy. just in case that you are familiar with the dataset. – Ammanna Azawi Jun 30 '22 at 17:23
  • You don't give us a reproducible example. Perhaps you should recast your question in terms of a much simpler toy dataset. – Nick Cox Jun 30 '22 at 20:04
  • My next guess: You are trying to use `///` interactively but that is allowed only in do-files and programs. I note that the error message is `/ invalid name`, which is not as you first reported. – Nick Cox Jun 30 '22 at 20:10
  • Thinks Nick for your help and comments. I will try your suggestion and the small example. In fact, I worked on the code trying to check the issue and did some modifications on the space between the first word of the second line and the following lines. I realized the variable was generated successfully although the same error message still appearing. – Ammanna Azawi Jul 01 '22 at 11:02

0 Answers0