Statalist


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

Re: st: Re: upper function within the loop


From   P C <calicep@yahoo.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Re: upper function within the loop
Date   Mon, 15 Jun 2009 12:12:05 -0700 (PDT)

Great! It works perfectly! Thanks a lot for the help, Martin!
Alice

--- On Mon, 6/15/09, Martin Weiss <martin.weiss1@gmx.de> wrote:

> From: Martin Weiss <martin.weiss1@gmx.de>
> Subject: st: Re: upper function within the loop
> To: statalist@hsphsun2.harvard.edu
> Date: Monday, June 15, 2009, 2:50 PM
> <>
> 
> If you are keen on doing this from first principles,
> 
> ***
> clear*
> set obs 100
> 
> gen w4hr5a=1
> gen w4hr7a=3
> gen w4hr6b=7
> gen w4hr9p=5
> 
> foreach var of/*
> */ varlist w4hr*{
>  rename `var' `=upper("`var'")'
> }
> ***
> 
> HTH
> Martin
> _______________________
> ----- Original Message ----- 
> From: "P C" <calicep@yahoo.com>
> To: <statalist@hsphsun2.harvard.edu>
> Sent: Monday, June 15, 2009 8:32 PM
> Subject: st: upper function within the loop
> 
> 
> > Hi,
> >
> > I have a problem that needs to be solved. I have a
> list of variables:
> >
> > w4hr5a w4hr6a w4hr7a w4hr8a w4hr9a
> > w4hr5b w4hr6b w4hr7b w4hr8b w4hr9b
> > ......
> > w4hr5p w4hr6p w4hr7p w4hr8p w4hr9p
> >
> > altogether there are 55 variables. All these
> variables' names need to be 
> > transformed into capital letters.
> >
> > Should I use upper function to do the transformation?
> How should I use the 
> > loop to deal with this kind of situation instead of
> writing out the 
> > command for each of the 55 variables?
> >
> > Thanks!
> >
> > Alice
> >
> >
> >
> >
> >
> >
> >
> > *
> > *   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/
> > 
> 
> *
> *   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/
> 


      


*
*   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