Announcement

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

  • Replace string value with a missing value (dot)

    I have a dataset with a variable "sex". I would like to know how can I replace a string value "missing" with a missing value (dot). Can you help me with the code?
    I send an example of the dataset below. Thank. you very much


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte(sex nchresp nch415resp)
    1 0 0
    1 0 0
    2 0 0
    1 0 0
    2 2 2
    2 1 1
    1 0 0
    2 0 0
    2 0 0
    2 0 0
    2 2 1
    2 0 0
    1 0 0
    1 2 1
    1 0 0
    2 2 2
    2 0 0
    2 0 0
    2 2 2
    2 2 2
    1 1 0
    2 0 0
    1 0 0
    1 0 0
    2 0 0
    2 0 0
    2 0 0
    1 0 0
    2 0 0
    2 0 0
    2 2 1
    2 3 3
    1 0 0
    1 0 0
    2 0 0
    2 2 2
    2 0 0
    1 0 0
    1 0 0
    2 1 1
    1 0 0
    1 0 0
    2 0 0
    1 0 0
    2 1 1
    2 3 1
    1 0 0
    2 0 0
    1 0 0
    2 0 0
    2 0 0
    1 0 0
    2 1 0
    2 1 0
    1 0 0
    1 0 0
    1 0 0
    2 1 1
    1 0 0
    2 1 0
    2 0 0
    2 1 1
    1 0 0
    2 0 0
    2 0 0
    1 0 0
    1 0 0
    2 0 0
    2 0 0
    2 0 0
    2 0 0
    2 1 1
    1 0 0
    2 0 0
    1 0 0
    1 0 0
    2 0 0
    1 0 0
    2 0 0
    2 0 0
    1 0 0
    2 0 0
    1 0 0
    2 0 0
    2 3 3
    1 0 0
    2 0 0
    1 0 0
    2 1 1
    1 0 0
    2 0 0
    2 2 0
    2 2 1
    1 0 0
    2 1 1
    2 0 0
    2 2 2
    2 0 0
    1 0 0
    2 0 0
    end
    label values sex c_sex
    label def c_sex 1 "male", modify
    label def c_sex 2 "female", modify
    label values nchresp c_nchresp
    label values nch415resp c_nch415resp







  • #2
    In the example data you show, sex is already a numeric variable. It has no missing values, and if it did, they would not appear as "missing," unless you specifically created a value label to do that. Perhaps this data is not from the data set you are looking for help with? Or perhaps it already is a value-labeled numeric variable in which some extended missing value is labeled as "missing," but you do not show any such observations in the example.

    For a more helpful response, please post a data example that illustrates the problem you wish to solve. The data you show exhibits no problem resembling what you have asked about.

    Comment

    Working...
    X