Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: How to genrate a variable containing some values of other variable


From   Alberto R Osella <arosella@irccsdebellis.it>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: How to genrate a variable containing some values of other variable
Date   Thu, 05 May 2011 15:15:47 +0200

Thank you again! Great.

Alberto R. Osella, MD, PhD
Laboratorio di Epidemiologia e Biostatistica
IRCCS Saverio de Bellis
Via Turi, 27
70013 Castellana Grotte (BA)
Italia
Tel:    +39 0804994655
Fax:    +39 0804994650
e-mail: arosella@irccsdebellis.it


Il 05/05/2011 15:02, Oliver Jones ha scritto:

Am 05.05.2011 14:55, schrieb Oliver Jones:
Hi,
maybe this works for you

gen int newvar = 0
local row = 0
forval i = 1(5)305 {
local row = `row' + 1
replace newvar = `i' in `row'
}

One word of caution:
When using steps of 5 maybe you want to go to 306 and
not just to 305? Otherwise the last observation will stay
zero.
To make the example work put a :

clear
set obs 62

in front of the previous code.

Best
Oliver
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index