Statalist


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

Re: st: How can I creat a new dataset with just one variable (80 obs.) from scratch ?


From   Anna Reimondos <[email protected]>
To   [email protected]
Subject   Re: st: How can I creat a new dataset with just one variable (80 obs.) from scratch ?
Date   Wed, 18 Nov 2009 12:16:53 +1100

Thanks Eric!
Just what I wanted.

On Wed, Nov 18, 2009 at 12:13 PM, Eric Booth <[email protected]> wrote:
> ***
> clear
> set obs 80
> gen age = _n
> ****
>
> __
> Eric A. Booth
> Public Policy Research Institute
> Texas A&M University
> [email protected]
> Office: +979.845.6754
>
>
>
> On Nov 17, 2009, at 7:07 PM, Anna Reimondos wrote:
>
>> Hello,
>> I would like to create a completely new dataset from scratch with just
>> one variable. I would like the variable (age) to have 80 observations,
>> increasing sequentially.
>>
>> Example:
>>
>> age
>> 1
>> 2
>> 3
>> 4
>> ..
>> 80
>>
>>
>> I have tried a few different things, eg
>>
>> clear
>> gen age=_n
>>
>> or ...
>>
>> clear
>> gen age=1
>> replace age=_n
>> keep if age<=80
>>
>>
>> but nothing happens....
>>
>> Does anyone know how to do this. I have tried searching for
>> information but it is one of those things which is hard to search for.
>> Obviously I open the data editor and input the values by manually but
>> I would prefer to have something reproducible.
>>
>> Thanks!
>> Anna
>> *
>> *   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/
>

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index