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

From |
Linn Renée Naper <linn.naper@ecgroup.no> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
st: generating variables conditional on others (again..) |

Date |
Thu, 30 Apr 2009 15:26:27 +0200 |

I would like to do something like this: forvalue m=1/12 { replace X3 = X2 in [X1==`m' + 1] } This is not possible, but I think it illustrates my problem as I need to tell stata to replace a variable (X3) with values (X2) from other observations identified by a third variable (X1). I have a sample with a date-identifier, variable X1 giving the current month and a variable X2 giving the mean price level for the same month. Thus, within the same month the variable is constant. Data have several years. Now I need a variable X3 which gives me the mean price level (X2) for the coming month (actually I will generate several variable for the price level for all months to come, but I guess the logic will be the same here). Thus, I need to generate a variable X3 (g X3=.) and then replace it with the values from X2 given in other observations. For month 1 (X1=1, January) X3 should contain the values of X2 when X1==2 (February) and so on. I know I posted a similar problem I while ago, but the structure of the data here is not the same, so I'm stuck again :( Linn * * 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/

**Follow-Ups**:**st: AW: generating variables conditional on others (again..)***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**st: RE: generating variables conditional on others (again..)***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**References**:**st: [iso-8859-1] Fisher´s exact test for rxc tables: one-tailed or two-ta iled[iso-8859-1] ?***From:*"Tiago V. Pereira" <tiago.pereira@incor.usp.br>

**Re: st: [iso-8859-1] Fisher´s exact test for rxc tables: one-tailed or two-ta iled[iso-8859-1] ?***From:*David Airey <david.airey@vanderbilt.edu>

- Prev by Date:
**Re: st: [iso-8859-1] Fisher´s exact test for rxc tables: one-tailed or two-ta iled[iso-8859-1] ?** - Next by Date:
**Re: st: [iso-8859-1] Fisher´s exact test for rxc tables: one-tailed or two-ta iled[iso-8859-1] ?** - Previous by thread:
**Re: st: [iso-8859-1] Fisher´s exact test for rxc tables: one-tailed or two-ta iled[iso-8859-1] ?** - Next by thread:
**st: RE: generating variables conditional on others (again..)** - Index(es):

© Copyright 1996–2015 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |