Announcement

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

  • What are .r values in a dataset? Can all values be replaced with 0?

    Hello,

    I have ".r" values in my dataset and I am unable to figure out why. Data comes from MSCI (KLD) database, so these values should be binary, being either 0 or 1.

    Is it possible to refer to all variables at once and recode the values of .r to 0? I have 168 variables, it would take quite a while to replace values one by one

    I have tried
    Code:
    recode
    , but didn't work for me.
    Last edited by Larry Wellings; 02 Jan 2021, 16:30.

  • #2
    I have ".r" values in my dataset and I am unable to figure out why. Data comes from MSCI (KLD) database, so these values should be binary, being either 0 or 1.
    Stata has a system missing value, which appears as a plan period (.), and 26 extended missing values which appear as .a .b .c , etc. through .z So .r is a missing value. As for why it is there--well you would have to look into the documentation for your MSCI (KLD) [whatever that is--you really shouldn't assume people know abbreviations like this] data set to find out. .r might specifically encode one particular reason for missingness, such as "refused to answer." Or maybe they just for some reason encoded all missing values as .r. If it's not in the documentation and you need to know, you would have to contact the people who distribute the data set.

    Is it possible to refer to all variables at once and recode the values of .r to 0? I have 168 variables, it would take quite a while to replace values one by one
    Yes it is possible, but unless you are certain that a missing value is, for all purposes you might apply this data to, equivalent to a zero value. You seem to imply in your first paragraph that,in fact, this should be a 0/1 variable, which would imply that the curators of the data, for reasons known only to themselves, coded it as .r/1 instead. If that's actually what happened, then you can do this:

    Code:
    foreach v of varlist whatever {
        replace `v' = 0 if `v' == .r
    }
    In the above, replace whatever by a list of all of the variables involved. If the names of the variables are at least partially systematic, you will be able to compose that list with one or a few wildcard expressions. If they are completely arbitrary names, you will have no choice but to type them all out. See -help varlist- if you are not familiar with wildcards.

    Comment


    • #3
      Thank you very much, this is very helpful! I was able to find out that for MSCI (KLD) .r means that the rating was not tracked in a particular year

      Comment


      • #4
        Originally posted by Larry Wellings View Post
        .r means that the rating was not tracked in a particular year
        Then .r is not equivalent to 0! It means we do not know the true value; it could be 0; it could also be 1.

        Why do you want to replace .r with 0?


        Edit:
        See

        Code:
        help mvencode
        for a convenient command to change missing values to numeric values. You will find that mvencode refuses to make any changes to your data (unless explicitly told to override existing values). The underlying reason is that missing values usually mean something other than (already present) numeric values.
        Last edited by daniel klein; 03 Jan 2021, 01:07.

        Comment


        • #5
          Thank you! You are right, I should rather treat them as missing values. I recoded the .r to . because initially Stata did not recognize some of my commands

          Comment


          • #6
            Originally posted by Larry Wellings View Post
            Thank you! You are right, I should rather treat them as missing values. I recoded the .r to . because initially Stata did not recognize some of my commands
            Hi Larry, thanks for your post. The values in KLD also confused me. Can I know what is the meaning of "." in KLD ESG dataset? How did you treat the observations with "." or ".r"? Many thanks.

            Comment

            Working...
            X