Announcement

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

  • Is there a command/function for this?

    Hi I have a column of encoded string values that contains different phrases (1,287,540) and 803 contain 'na'

    Is there a function to create a dummy variable that will code all phrases (1,287,540) as 1 EXCEPT the phrase 'na' which is to be coded as 2 ?

    Thanks

  • #2
    Try:

    Code:
    generated wanted = (that_variable == "na") + 1
    "Encoded string" is a bit ambiguous. If it's still string then the above should work. But if it has has been encoded into numeric with a coding scheme, then you can find out what number is used to code for "na". Or, you may use destring to convert the target variable back into a sting. Without knowing more about the data format, it's hard to tell.
    Last edited by Ken Chui; 03 May 2022, 07:55.

    Comment


    • #3
      Yes, I've found a way out
      I've encoded , used list no and used the number .
      Thanks

      Comment

      Working...
      X