Announcement

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

  • "Invalid Name"

    Hi!

    I wonder what is wrong here, can anyone help me? I'm using encode, because it is a sting variabel.

    Click image for larger version

Name:	invalid name.JPG
Views:	1
Size:	98.3 KB
ID:	1523426

  • #2
    You have created your own syntax for -encode- and Stata, understandably, does not understand it. It appears that you have taken the correct syntax for the -recode- command and tried to use it with -encode-. That's not possible. I infer from what you wrote that you want to get rid of the 5 digit codes (although most of them seem to be 6 digits!) altogether and just have a value labeled numeric variable. So what you need to do is run a series of -replace- command where you replace each of the codes by the name of the country that you want. Then you can -encode- that changed version of the variable. Be sure to use the correct -encode- syntax: see -help encode-.

    Added: In the future, please bear in mind that the use of screenshots to show code and results is not very helpful. Had you provided the results by copy/pasting from your Results window or log file into the data editor, surrounded by code delimiters, you would have had a display of the information that is both readable and editable. That way I might have copied the code and edited it into form, and pasted it back here in this response. But a screenshot does not enable me to do that, and I didn't want to take the time to type it all out. If you are not familiar with code delimiters, read Forum FAQ #12.
    Last edited by Clyde Schechter; 05 Nov 2019, 11:30.

    Comment

    Working...
    X