Hi Tirthankar,
May be this time I think I would be able to make it clear
to you. For example, say hid indicates plant id (of
subject plant) and nid indicates nearby plant ids, dist
stands for distance between two plants,and dates indicate
inspection date. Now what I need is information on nearby
plants (along with their distance from subject plants and
FD types) whose inspection took place within a year from
the inspection date of each subject plants. Therefore,
each row should contain a subject plant (hid) with its
inspection date(DATE) and various nearby plants (nids)
along with their respective inspection dates, distances
and FD types. For example, if B & C are near to subject
plant A then each row of the dataset should include A
(hid), its inspection date (DATE), B (nid) along with its
all possible inspection dates (from table 1), distance
(from table 2) and all possible FD types (from table 1),
and then similar information for nearby plant C. I have
almost 45,000 such observations.
Thanks
Arnab
> Here is another stab at a solution. I am still not very clear about
> how you want this done though, so this might not be what you want:
> ***************************************
> clear*
> input str2 hid str15 date fd
> A "01/03/2005" 0
> A "04/05/2006" 1
> B "02/03/1999" 1
> B "09/07/2004" 1
> B "09/07/2004" 0
> C "05/02/2004" 0
> C "03/11/2004" 1
> D "05/08/1998" 0
> end
> save 1, replace
> ******************
> rename hid nid
> bys nid: g j=_n
> reshape wide date fd, i(nid) j(j)
> rename nid nid1
> save 2, replace
> clear
> ******************
>
> input str2 hid str2 nid1 dist1 str2 nid2 dist2
> A B .75 C .25
> B D .35 A .75
> C E .65 A .25
> D B .35 "" .
> end
> joinby nid1 using 2, unmatched(master)
> save 3, replace
> ******************
>
> use 1
> joinby hid using 3
> drop _merge
> list, clean
> ***************************************
>
> T
>
>
> On Sat, Aug 22, 2009 at 4:59 AM, <[email protected]> wrote:
>> Hi Tirthankar,
>>
>> Thanks for the reply. However, this is not the one I need. Basically,
>> for
>> each observation I need hid date their corresponding nids and those
>> nid's
>> all possible dates. If you look at my table 3 you will understand what
>> exactly I want. In your solution what I am getting is that each row
>> incorporates within group hid dates only.
>>
>> Thanks.
>>
>> Arnab
>>
>>
>>
>>
>>> <>
>>> Is this perhaps%
*
* 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/