I assume variables
Epid
Att
Ned
Yag
Pallad
and no identifiers. Then
egen id = seq(), block(2)
egen coll = seq(), to(2)
reshape wide Epid Att Ned Yag Pallad, i(id) j(coll)
renvars *1, postdrop(1)
drop Pallad2
renvars *2 \ Gord Molb Nur Zn
destring, replace
where -renvars- can be found via -search-.
Scott Merryman
On Nov 8, 2007 5:32 AM, b. water <[email protected]> wrote:
> stata 8.2,
>
> would appreciate advice on how the following data management
transformation can be undertaken:
>
> at the moment data look like this:
>
> Epid Att Ned Yag Pallad
> Gord Molb Nur Zn
> Yes 5 twice Off Present
> 2 3 PRN no
> No 4 no On Present
> 0 1 no yes
> . . . . .
> . . . .
> . . . . .
> . . . .
> Yes 5 twice Off Present
> 2 3 PRN no
> No 4 no On Present
> 0 1 no yes
>
> i want to change it so it looks like this:
>
> Epid Att Ned Yag Pallad Gord Molb Nur Zn
> Yes 5 twice Off Present 2 3 PRN no
> No 4 no On Present 0 1 no yes
> .
> .
> .
> .
> Yes 5 twice Off Present 2 3 PRN no
> No 4 no On Present 0 1 no yes
>
>
Like this?
clear
tempfile foo1 odd even
input str4 Epid str4 Att str5 Ned str3 Yag str7 Pallad
Gord Molb Nur Zn
Yes 5 twice Off Present
2 3 PRN no
No 4 no On Present
0 1 no yes
end
l
save `foo1',replace
keep if mod(_n,2)
drop Pall
ds
foreach l in `r(varlist)' {
local a `=`l'[1]'
rename `l' `a'
}
drop in 1
save `odd', replace
use `foo1',clear
keep if ! mod(_n,2)
save `even', replace
merge using `odd'
drop _m
l
*
* 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/