Announcement

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

  • 'drop if' command not working with several sets of quotations

    Greetings,

    I'm having trouble dropping a variable in my dataset.

    I'm trying to write a command like this:

    drop if participant_id == "{"ImportId":"QID2_TEXT"}"

    This, however, is not working. I've tried several variations of the quotation marks but can't get it to run. I think all the quotation marks are throwing it off and the entire text inside the outermost quotation marks is not all showing up in red like it usually does.

    Any insights would be greatly appreciated!

  • #2
    I think what you want is
    Code:
    drop if participant_id == `"{"ImportId":"QID2_TEXT"}"'
    You cannot nest expressions quoted with " " inside each other because it is impossible for the parser to distinguish the beginning of a nested quote from the end of a single quoted string followed by the start of another. This is why Stata offers compound double quotes, which can be nested because the opening quote `" is distinct from the closing quote "'. Read all about it at -help quotes-.

    Added: It is the norm in this community that we use our real given and surnames as our username, to promote collegiality and professionalism. Unless Fiat Lux is your real name, please contact the system administrator by clicking on Contact Us in the lower right corner of the page and requesting a change of your user name. (You cannot make this change by editing your profile, unfortunately.)
    Last edited by Clyde Schechter; 02 Aug 2018, 14:49.

    Comment

    Working...
    X