Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Using a for loop to generate a number list


From   "J. J. W." <[email protected]>
To   [email protected]
Subject   st: Using a for loop to generate a number list
Date   Mon, 13 Jan 2014 16:43:49 +0100

Dear all,

I have a small question, considering the following code:

local temp = "0 "

foreach i in 1/10 {
 local temp = `temp' + `i' + " "
}

What I hope to achieve is a number list 0 1 2 3 4 5 6 7 8 9 10 and I
could use that in the cut function (e.g. cut(`temp')), however a few
things happened:

- I cannot cast the i to a string, I already tried using string(`i'),
however this also doesn't work. Could someone demonstrate how one
should do this and what I am doing wrong?

Thanks in advance!

Yours sincerely,

Wen Jun Jie
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index