[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Dev Vencappa" <lexdvv@nottingham.ac.uk> |

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

Subject |
Re: st: renaming a variable from the contents ofits observation |

Date |
Thu, 01 Jul 2004 14:56:30 +0100 |

that's brilliant. It has worked fine without problem Many thanks Dev >>> dkantor@jhu.edu 07/01/04 02:52pm >>> At 02:36 PM 7/1/2004 +0100, Dev Vencappa wrote: >Dear all > I have a large data set containing variables v9 to v200. > >variable names: v9 v10 v11 v12 v13 v14 ........ ..... v200 > Observation 1 TAN TAN TAL TAN CAN TLM > Observation 2 4108 4103 4108 5214 1235 1108 > >Each of these numbers in the second row of observations represents a >particular variable code. What I want is to prefix each of these numbers >with the text in the first row of observation e.g. TAN4108 TAN4103 CAN1235 >TLM1108, etc. After that, I want to rename my existing variables >(v9,v10,v11,...-v126) to these newly created variables. Presumably these variables are all of string type -- as seen by the contents of the first observation. Thus, even though there are values 4108, 4103, etc. in the 2nd observation, they are really string values. Then you can do this (untested): forvalues k = 1/200 /* or whatever the maximum is */ { local newname = v`k'[1] + v`k'[2] ren v`k' `newname' } I hope this helps. -- David David Kantor Institute for Policy Studies Johns Hopkins University dkantor@jhu.edu 410-516-5404 * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ This message has been scanned but we cannot guarantee that it and any attachments are free from viruses or other damaging content: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

- Prev by Date:
**Re: st: renaming a variable from the contents of its observation** - Next by Date:
**st: .wmf or .emf ? Can we edit the graphs outside Stata? How** - Previous by thread:
**st: Italicizing an organisms scientific name in a graph** - Next by thread:
**st: .wmf or .emf ? Can we edit the graphs outside Stata? How** - Index(es):

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