Statalist


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

Re: st: Help with mathematical operation


From   Ada Ma <heu034@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Help with mathematical operation
Date   Thu, 10 Sep 2009 20:22:02 +0100

Do you mean, say, you have a data set with 8 observations, now you
want to create a data set with, say, 64 observations going from 1x1 to
1x8 to 8x1 to 8x8?

If my guess is correct the command you need is -expand-.

expand 8
bys originalvar: gen temp=_n

gen targetvar=originalvar*temp   /* this is if you want to have a
numeric variable */
gen targetvar=string(original)+"*"+string(temp)  /* this is if you
want to have a string variable */





On Thu, Sep 10, 2009 at 6:18 PM, Burnett, Tim
<Tim.Burnett@ccpanel.gsi.gov.uk> wrote:
> Hello,
>
> I am at the end of my tether with Stata 10 and was hoping someone could help me:
>
> I have a dataset which I am trying to manipulate:
>
> Assuming the following variable:
>
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
>
> I am trying to create a variable which will show:
>
> 1*1
> 1*2
> 1*3
> 1*4
> .
> .
> .
> 2*1
> 2*2
> 2*3
> 2*4
> .
> .
> .
> ...and so on.
>
>
> I really don't know where to look as I can't think what this mathematical operation would be called. Maybe I'm just dim.
>
> Many thanks,
>
> Tim Burnett
>
> **********************************************************************
> If you have received this email and it was not intended for you,
> please let us know, and then delete it.  Please treat our
> information in confidence, as you would expect us to treat yours.
>
> All our information systems may be monitored to ensure
> that they are operating correctly.  Furthermore, the content of
> emails and other data on these systems may be examined,
> in exceptional circumstances, for the purpose of investigating
> or detecting any unauthorised use.
>
>
>
>
> The original of this email was scanned for viruses by the Government Secure Intranet virus scanning service supplied by Cable&Wireless in partnership with MessageLabs. (CCTM Certificate Number 2009/09/0052.) On leaving the GSi this email was certified virus free.
> Communications via the GSi may be automatically logged, monitored and/or recorded for legal purposes.
>
>
> *
> *   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/
>



-- 
Ada Ma
Research Fellow
Health Economics Research Unit
University of Aberdeen, UK.
http://www.abdn.ac.uk/heru/
Tel: +44 (0) 1224 555189
Fax: +44 (0) 1224 550926

*
*   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   |   What's new   |   Site index