Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Matthew Mroczek <matthew.mroczek@connect.qut.edu.au> |

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

Subject |
st: How to generate a variable made up of sections of other variables |

Date |
Thu, 5 May 2011 09:34:02 +0000 |

Hi All, I am using Stata/SE 11.2 for Windows (64-bit x86-64) Born 30 Mar 2011 and have been trying to create a variable made up of specific sections of a number of other variables. So essentially I would like to replace eg the 60-70th values in my variable with the 20-30th values of another. Also if it complicated matters id like to work in a loop so something along the lines of this forvalues c = 1(1)5{ forvalues n = 1(1)5{ forvalues x = 1(1)5 { sum variable gen `c'`n'`x' = r(sum) } quietly gen p`c'`n' = p`c'`n'1 in 1 quietly replace p`c'`n' = p`c'`n'2 in 2 quietly replace p`c'`n' = p`c'`n'3 in 3 quietly replace p`c'`n' = p`c'`n'4 in 4 quietly replace p`c'`n' = p`c'`n'5 in 5 } quietly gen p`c' = pds`c'1 in 1/5 quietly replace p`c' in 6/10 = p`c'2 in 1/5 quietly replace p`c' in 11/15 = p`c'3 in 1/5 quietly replace p`c' in 16/20 = p`c'4 in 1/5 quietly replace p`c' in 21/25 = p`c'5 in 1/5 } So if anyone could point me in the right direction I'd be very grateful. Cheers, Mateusz Mroczek Queensland University of Technology * * 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: RE: How to generate a variable made up of sections of other variables***From:*Nick Cox <n.j.cox@durham.ac.uk>

- Prev by Date:
**Re: st: Why F-test with regression output** - Next by Date:
**st: RE: 5 year panels** - Previous by thread:
**st: Midas** - Next by thread:
**st: RE: How to generate a variable made up of sections of other variables** - Index(es):