Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: program for similiar commands


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: program for similiar commands
Date   Wed, 11 Jun 2008 10:20:39 +0100

The sequence of T* variables is more irregular than that. 

Here is another way to handle the leading zero issue. 

local J 11 16 21 26 31 36 41 46 50 54 58 
tokenize `J' 
forval i = 1/11 { 
	local I : di %02.0f `i' 
	gen child`I'_HH = 1 
	replace child`I' = 0 if T099``i''00 ~= 1 
}

Nick
[email protected] 

Martin Weiss

Here is a shot at the problem:

********
loc j=1100

forv i=1/9{
	g child0`i'_HH=1
	replace  child`i'_HH=0 if T0991`j'~=1
	loc j `=`j'+500'
}

loc j=5400

forv i=10/11{
	g child0`i'_HH=1
	replace  child`i'_HH=0 if T0991`j'~=1
	loc j `=`j'+500'
}
********

Man Jia

I was wondering if anyone could give me some hint of how to simply the 
following commands:

---------------------------------------------
gen child01_HH=1
replace  child01_HH=0 if T0991100~=1
gen child02_HH=1
replace  child02_HH=0 if T0991600~=1
gen child03_HH=1
replace  child03_HH=0 if T0992100~=1
gen child04_HH=1
replace  child04_HH=0 if T0992600~=1
gen child05_HH=1
replace  child05_HH=0 if T0993100~=1
gen child06_HH=1
replace  child06_HH=0 if T0993600~=1
gen child07_HH=1
replace  child07_HH=0 if T0994100~=1
gen child08_HH=1
replace  child08_HH=0 if T0994600~=1
gen child09_HH=1
replace  child09_HH=0 if T0995000~=1
gen child10_HH=1
replace  child10_HH=0 if T0995400~=1
gen child11_HH=1
replace  child11_HH=0 if T0995800~=1
------------------------------------------

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