Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: SV: RE: Making symmetry


From   "Alexander" <[email protected]>
To   <[email protected]>
Subject   st: SV: RE: Making symmetry
Date   Sun, 13 Apr 2003 18:36:18 +0200

Hi,

Thx, Nick Cox solved the problem with the following code:

This will work if the number of distinct 
levels in -Id2- is modest: 

ssc inst levels 
levels Id2 
replace Id2 = . 
foreach l of local levels { 
	qui replace Id2 = `l' if Id1 == `l' 
} 

Slow but sure with arbitrarily large data sets: 

gen draft = . 
forval i = 1 / `=_N' { 
	qui replace draft = Id2[`i'] if Id1 == Id2[`i'] 
} 
replace Id2 = draft 
------------------------------------------------------------

-----Opprinnelig melding-----
Fra: [email protected]
[mailto:[email protected]] P� vegne av Kostova
Deliana (HXX1DAK)
Sendt: 11. april 2003 14:25
Til: [email protected]
Emne: st: RE: Making symmetry


alexander - -fillin- might work.
deliana

-----Original Message-----
From: Alexander [mailto:[email protected]]
Sent: Friday, April 11, 2003 5:34 AM
To: [email protected]
Subject: st: Making symmetry


Dear Statalister,

I have 2 ID-variables:

Id1	Id2
1	1
2	3
3	5
4	.
5	.

And I want the variabels to be symmetric in relation to ID1

Like this:

Id1	Id2
1	1
2	.
3	3
4	.
5	5

Any suggestions would be greatly appreciated.

Best regards,
Alexander Severinsen


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


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