Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: From: [email protected]


From   Scott Merryman <[email protected]>
To   [email protected]
Subject   Re: st: From: [email protected]
Date   Fri, 13 Aug 2010 15:06:47 -0500

You can with 3 mata commands:

. sysuse auto
(1978 Automobile Data)

. replace mpg = . if runiform()<.9
(66 real changes made, 66 to missing)

. putmata mpg
(1 vector posted)

. mata:mpg = sort(mpg,1)

. getmata mpg, replace

. l mpg price in 1/10

     +--------------+
     | mpg    price |
     |--------------|
  1. |  15    4,099 |
  2. |  16    4,749 |
  3. |  18    3,799 |
  4. |  23    4,816 |
  5. |  25    7,827 |
     |--------------|
  6. |  25    5,788 |
  7. |  26    4,453 |
  8. |  29    5,189 |
  9. |   .   10,372 |
 10. |   .    4,082 |
     +--------------+


Scott


On Fri, Aug 13, 2010 at 2:47 PM,  <[email protected]> wrote:
> Dear all,
>
> I wish to delete "cells" (not observations, aka rows) that have missing
> values for variable x only within x. Hence,
>
> "drop if x==."
>
> would not work because it will delete the observations across all
> variables, to explain graphically, I want something that looks like this:
>
> variable x
> 0.998
> .
> .
> .
> 0.658
> .
> 7.801
> .
>
> to become:
> 0.998
> 0.658
> 7.801
>
> without disturbing the other variables in the dataset. Manually
> manipulating in Excel is not an option because this is done half way
> through a do file and must be done by written commands. Stata is very easy
> to use to drop variables and observations, but can it delete specific
> "cells"?
>
> Can anyone help here?
>
> Any advice much appreciated,
> David
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index