Statalist


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

Re: st: Re: Re: dataset generation


From   Nikolaos Pandis <[email protected]>
To   [email protected]
Subject   Re: st: Re: Re: dataset generation
Date   Sun, 19 Apr 2009 23:31:29 -0700 (PDT)

Dear Martin,

That was great!

Thank you very much.

Nick
--- On Sun, 4/19/09, Martin Weiss <[email protected]> wrote:


From: Martin Weiss <[email protected]>
Subject: st: Re: Re: dataset generation
To: [email protected]
Date: Sunday, April 19, 2009, 7:52 PM


<>

Sorry, you said you wanted separate lb/ub for your newvars:

****
clear*
set obs 100

gen id=_n

//lower bound for var1
local a1 40
//upper bound  for var1
local  b1 100

//lower bound for var2
local a2 56
//upper bound  for var2
local  b2 76

//lower bound for var3
local a3 74
//upper bound  for var3
local  b3 88

//lower bound for var4
local a4 45
//upper bound  for var4
local  b4 67

forv i=1/4{
gen var`i'=`a`i''+int((`b`i''-`a`i''+1)*runiform())
}

gen var5cat=0
replace var5cat=1 in 51/100

list, noobs h(30)
****


HTH
Martin
_______________________
----- Original Message ----- 
From: "Martin Weiss" <[email protected]>
To: <[email protected]>
Sent: Sunday, April 19, 2009 6:47 PM
Subject: st: Re: dataset generation


><>
>
> ***
> clear*
> set obs 100
>
> gen id=_n
>
> //lower bound
> local a 40
> //upper bound
> local  b 100
>
>
> forv i=1/4{
> gen var`i'=`a'+int((`b'-`a'+1)*runiform())
> }
>
> gen var5cat=0
> replace var5cat=1 in 51/100
>
> list, noobs h(30)
> ***
>
>
> HTH
> Martin
> _______________________
> ----- Original Message ----- 
> From: "Nikolaos Pandis" <[email protected]>
> To: <[email protected]>
> Cc: <[email protected]>
> Sent: Sunday, April 19, 2009 6:28 PM
> Subject: st: dataset generation
>
>
>> Hi to all,
>>
>> I would like to generate 4 variables that contain  a set of integers in a 
>> range from 40-100.
>> I would like to select the range per variable.
>> The total number of observations per variable would be 100.
>> Finally, I would like to create a categorical variable with 0 or 1.
>> The first 4 continuous variables, contain 50 values of category 0 and 50 
>> of category 1:
>>
>> id  var1  var2  var3 var4 var5cat
>>
>> 1   45    43     44     46    0
>> 2   43    42     48     49    0
>> .............................
>> 50   56     48    54     53    0
>>
>> 51   45    43     44    46    0
>> 52   43    42      48   49    0
>> .............................
>> 100   50     48    54     53   0
>>
>> Thank you very much.
>>
>> nick
>>
>>
>>
>> *
>> *   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/



      

*
*   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