Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Data Manipulation


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: st: Data Manipulation
Date   Wed, 27 Jun 2007 16:03:04 -0400

Raphael Fraser <[email protected]>:
This is an ill-formed question.  In the example given, one can simply
-clear- and then -input- the new data.  In a general case of which
this is supposed to be an example, should values be matched on order
of occurence in the current sort order?  Sorted from lowest to
highest?  Are there the same number of nonmissing x and y
observations?  Is one always missing when the other is not?

One approach assuming the current sort order defines the problem would be
input x   y
1   .
2   .
3   .
.   4
.   5
.   6
end
g long obs=_n
su obs if !mi(x)
local N=r(max)
replace y=y[_n+`N'] in 1/`N'
drop if _n>`N'
drop obs

On 6/27/07, Raphael Fraser <[email protected]> wrote:
How does one get from dataset1 to dataset2?

DATASET1
    x   y
    1   .
    2   .
    3   .
    .   4
    .   5
    .   6

DATASET2
   x  y
   1  4
   2  5
   3  6
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index