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]
Re: st: R: Creating a dummy dataset in Stata
From
Sergiy Radyakin <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: R: Creating a dummy dataset in Stata
Date
Mon, 8 Jul 2013 23:21:01 -0400
Carlo, building on your example some changes:
1) group should be repeated for every three observations, so we can
generate it automatically
2) id we can also generate automatically
3) if confidence interval is symmetric around the point estimate, we
need only one bound;
Amal, if all of the above is true, then you need something like this,
where you only type two columns, the rest is generated around it:
clear
input RR LL95CI
2 1.5
1 0.5
3 1.5
end
generate id=_n
generate group=ceil(id/3)
generate UL95CI=RR+(RR-LL95CI)
order id group LL95CI RR UL95CI
list
Best, Sergiy Radyakin
On Mon, Jul 8, 2013 at 10:31 AM, Carlo Lazzaro
<[email protected]> wrote:
> Dear Amal,
> I am not clear about the meaning of a "dummy dataset".
> Anyway, let's assume that you still have the data you mentioned on your post
> and your need is inputting them in a .dta file.
> Limiting the example at 3 observation:
>
> input id RR LL95CI UL95CI group_var
>
> 1 2 1.5 3 1
> 2 1 0.5 1.6 3
> 3 3 1.5 2.6 2
> end
>
> If your need is to sort group_var in ascending order, you can type:
>
> - sort group_var -
>
> No better contribution springs to my mind. Others on the list can give you
> more skillful advices.
>
> Kindest regards,
> Carlo
> -----Messaggio originale-----
> Da: [email protected]
> [mailto:[email protected]] Per conto di Amal Khanolkar
> Inviato: lunedì 8 luglio 2013 15:50
> A: [email protected]
> Oggetto: st: Creating a dummy dataset in Stata
>
> Hi,
>
> I would like to create a dummy dataset in Stata. Say I would like to have a
> dataset with 4 variables as follows:
>
>
> 1. ID
> 2. Relative risks
> 3. Corresponding 95% CI's for RRs
> 4. A group variable that groups 3 RRs together consecutively from top to
> bottom.
>
> I know I have 66 IDs and 66 RRs and thus 22 groups (three RRs in each
> group).
>
> I start with setting the number of observations to 66:
>
> set obs 66
>
> I now have no idea how to enter the RR, 95% CI and the group number for each
> observation.
>
> Any tips?
>
> Thanks ahead,
>
>
>
> /Amal
> *
> * 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/
>
>
> *
> * 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/
*
* 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/