Dear Friends
I have following two datasets
Dataset 1 with 2 rows
Data set 2 with 5 rows
I want the resultant dataset to be 2x5 = 10 rows for the household
Data set 1.
OBVS1ID HHID PersonID PersonCharacteristcis
25 1 1
26 1 2 .....Matrix(X1)
Data set 2 (from Census)
OBVS2ID HHID PersonID Person&other_characteristics
A21 1 1
A22 1 2
A23 1 3 .....Matrix(X2)
A24 1 4
A25 1 5
Resultant data set
OBVS1ID OBVS2ID HHID PersonID1 PersonID2 Person_charac
Person& other charac
25 A21 1 1 1
25 A22 1 1 2
25 A23 1 1 3
25 A24 1 1 4
25 A25 1 1 5
26 A21 1 2 1
26 A22 1 2 2
26 A23 1 2 3
26 A24 1 2 4
26 A25 1 2 5
----- Original Message -----
From: "Scott Merryman" <[email protected]>
To: <[email protected]>
Sent: Thursday, April 17, 2003 10:32 PM
Subject: st: Re: SUR on stacked data
> ----- Original Message -----
> From: "Vimalanand S. Prabhu" <[email protected]>
> To: <[email protected]>
> Sent: Wednesday, April 16, 2003 11:01 PM
> Subject: st: SUR on stacked data
>
>
> > Dear Friends,
> >
> > I have data stacked into columns. I want to conduct a SUR on this data
> where
> >
> > Y1 = f(x1)
> > Y2= f(x2)
> > where y1, x1 and y2, x2 are variables for different gender.
> > Note that both Xs are not same (else SUR is algebriacally equivalent to
> > OLS).
> >
> > Do you know how to convert a stacked dataset into a formal where I can
> > directly use "sureg" command for SUR model?
> >
> > Thanks,
> >
> > Prabhu
> >
>
> Prabhu,
>
> I believe the following little program will work. It creates a series of
> new variables for each group beginning at the same observation number as
the
> first group.
>
> Example:
>
> use http://www.stata-press.com/data/r8/grunfeld.dta
> separate2 invest mvalue kstock, group(company)
>
> and then
> sureg (invest1 mvalue1 kstock1) (invest2 mvalue2 kstock2) ....
>
>
> I hope this helps,
> Scott
>
>
> -----start of separate2.ado-----
> program separate2
> version 8.0
>
> syntax varlist, group(varname)
>
> tempname Vals /*Pilfered from Nick Cox's -levels- */
> qui tab `group' , matrow(`Vals')
> local nvals = r(r) -1
> local sep " "
> forval i = 1 / `nvals' {
> local val = `Vals'[`i',1]
> if `i' < `nvals' local vals "`vals'`val'`sep'"
> else local vals "`vals'`val'"
> }
> local levels `"`vals'"'
>
> qui sum `group'
> local min = r(min)
>
> foreach var of varlist `varlist' {
> local i = `min'
> local num = 0
> separate `var', by(`group')
> foreach x of local levels {
> qui sum `var'`i'
> local num = `num' + r(N)
> local i = `i' + 1
> replace `var'`i' = `var'`i'[_n+`num']
> }
> }
>
> end
>
>
> *
> * 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/
>
*
* 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/