Announcement

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

  • Replacing string variables to missing

    Good evening!

    I have a large dataset which I am cleaning- variables currently have a mix of missing data coded as ".", "Missing" or "-9". I am trying to get all missing data coded as "."

    All my variables are in byte format

    When I run;

    replace var1=. if var1==-9 it is successful

    But attempting;

    replace var2=. if var2=="Missing" brings up the error message "type mismatch" (or "Missing not found" if I remove the quotation marks)

    I've tried many variations including: | replace var2=. if var2==Missing | replace var2="." if var2=="Missing" | var2=. if var2="Missing" etc..., but cannot find a solution to this

    If anyone could point me in the right direction that would be great

  • #2
    Time of day references on forums make little size in a spherical world!

    Byte is a storage type, not a format.

    At some point, value labels have been defined for your variable. It's evidently a numeric variable, but you are seeing the value labels.

    Code:
    label list
    will show you the numeric values that will make management easier.


    Comment


    • #3
      The confusion Nick cites is so pervasive among new users that I always encourage them, in the strongest terms, to use -fre- (-ssc install fre-) for oneway frequency distributions rather than -tabulate-. The output produced by -fre- serves as a constant reminder of the difference between values and labels. (That output strongly resembles what SPSS produces, and is about the only thing I recall liking better in SPSS than in Stata.<grin>) For similar reasons, I wish that -nolabel- was the default option on -list- and -browse- for any new user.

      Comment

      Working...
      X