[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
[no subject]
Part of an answer to your question here was given yesterday in response
to an earlier question of yours.
The example you give is of a numlist with 91 members.
Here is some technique.
clear
numlist "0(1)60 60(5)120 120(10)180 180(20)360"
ret li
local n : word count `r(numlist)'
set obs `n'
tokenize "`r(numlist)'"
gen x = .
qui forval i = 1/`n' {
replace x = ``i'' in `i'
}
Advice on adapting this to your circumstances could follow if you said
what they are. Things will be easiest if you already have 91 or more
observations in memory, so that the code would then be
numlist "0(1)60 60(5)120 120(10)180 180(20)360"
local n : word count `r(numlist)'
tokenize "`r(numlist)'"
gen x = .
qui forval i = 1/`n' {
replace x = ``i'' in `i'
}
Nick
[email protected]
Serguei Kaniovski
Alan, "fill" is the right command, but the results are strange...
for example
egen x=fill(0(5)60)
produces the correct sequence, while the more compex
egen y=fill(0(1)60 60(5)120 120(10)180 180(20)360)
produces just the simple 1 to _N with step 1. The latter command does
not
seem to tale the arguments correctly,
*
* 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 |