Statalist The Stata Listserver


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

st: RE: FW: Using wild card syntax for variable lists as a program argument


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: FW: Using wild card syntax for variable lists as a program argument
Date   Fri, 19 Jan 2007 17:48:10 -0000

program recodevariables
	version 9 
	syntax varlist
	tokenize `varlist' 

	/// variables are `1' `2' `3' etc. 

Nick 
[email protected] 

Dupont, William
 
> I need to write a program that does the same manipulation on a large
> number of variables.  I have written a program that does what I want
> that works as follows
> 
>    program recodevariables
>    ...manipulate each variable in the argument list  
>    end 
>    use data.dta 
>    recodevariables tcat tdog tcow 
>    ...
> 
> The preceding program manipulates the variables tcat, tdog and tcow in
> the way I want.
> 
> Is it possible to rewrite the program so that I can execute it as
> 
> recodevariables t*
> 
> ?  Inside recodevariables, Stata interprets t* as a single 
> argument.  Is
> there a way that I can expand this argument so that argument 
> `1' is tcat
>         argument `2' is tdog and
>         argument `3' is tcow?
> 
> If so, I know how to write the rest of the program.  If not, is there
> some other way of writing this program using the wildcard variable
> naming convention that I should know about?

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



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