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   Oliver Jones <ojones@wiwi.uni-bielefeld.de>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: How to genrate a variable containing some values of other variable
Date   Thu, 05 May 2011 14:55:06 +0200

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'
}

Best
Oliver

Am 05.05.2011 14:50, schrieb Alberto R Osella:
Dear Statalisters,

I'm workin with Stata 11.2 on Windows and have the following problem:

I has a variable which takes on values from 1 to 301 and I want to generate a new variable
which should take on the following values 1,6,11,...,305 (1(5)305).

So if anyone could point me in the right direction I'd be very grateful.
Cheers



--
Universität Bielefeld
Fakultät für Wirtschaftswissenschaften
Lehrstuhl für Ökonometrie und Statistik
- -
Bielefeld University
Faculty of Business Administration and Economics
Chair of Econometrics and Statistics
- -
Raum / room:  V9-110
Tel / phone:  +49 (0)521 106 4871
---
*
*   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