Announcement

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

  • Why Stata doesn't recognize empty values

    Hi,

    I have recently created a new variable mothergrad1 and there are empty values when I used the function count. However, when I wanted to replace the empty values with 0, no real changes were made. Why is that so?

    This was stata output:

    count if mothercollegegrad1==.
    26344

    replace mothercollegegrad1=0 if mothercollegegrad1==.
    (0 real changes made)

    Thank you.


    Last edited by Angie Heng; 08 Mar 2019, 17:45.

  • #2
    My first guess is that the two commands you show were not copied correctly from Stata and one of them actually had some sort of error. My second guess is that these two commands had between them some other commands that changed the data so that there were no longer missing values. I note that you describe your problem as creating a new variable mothergrad1 but your code shows the variable mothercollegegrad1.

    The following example shows that what you reported in post #1 should have worked.
    Code:
    . sysuse auto, clear
    (1978 Automobile Data)
    
    . count if rep78==.
      5
    
    . replace rep78=0 if rep78==.
    (5 real changes made)
    Please review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. See especially sections 9-12 on how to best pose your question. It's particularly helpful to copy commands and output from your Stata Results window and paste them into your Statalist post using code delimiters [CODE] and [/CODE], as described in section 12 of the FAQ.

    Last edited by William Lisowski; 08 Mar 2019, 19:27.

    Comment

    Working...
    X