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: RE: data management questions


From   David Bai <[email protected]>
To   [email protected]
Subject   Re: st: RE: data management questions
Date   Mon, 23 Aug 2010 21:12:52 -0400

Thank you very much, Martin!


-----Original Message-----
From: Martin Weiss <[email protected]>
To: [email protected]
Sent: Sat, Aug 21, 2010 7:49 am
Subject: st: RE: data management questions



<>


ad (1):


***********
clear*

inp byte ID int NID
1 100
2 100
3 104
4 102
5 104
end

list, noo

preserve
bys NID: keep if _n==1
drop ID
l
save mynids, replace
restore
***********


HTH
Martin


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of David Bai
Sent: Samstag, 21. August 2010 12:52
To: [email protected]
Subject: st: data management questions

Dear all,

    I have two questions regarding data management, and would
appreciate it if anybody can help.

(1) If I have a datafile like this:

ID(individual id)         NID(neighborhood id)
1                                   100
2                                   100
3                                   104
4                                   102
5                                   104

How can I create a datafile for neighborhood ID variable like this?:
NID
100
102
104

(2) Now since I have the complete list of NIDs (suppose there are 100
neighborhoods), I'd like to use this NID file to merge with another
data file (dataset Two, which has neighborhood ID variable and
time-varying variables. Dataset Two has 200 neighbors) like this:
NID                year              var1
100                1                   850
100                2                   600
101                1                   90
102               1                   600
102                2                  400
103                1                  500
103                2                  400
103                3                  506


I only want to keep the 100 neighborhoods that appear in the NID file,
What syntax I can use to merge the two data files for the 100
neighbors? Thank you very much.

*
*   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/

*
*   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