Statalist


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

Re: st: Re: program to generate variable list as input for other program


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: Re: program to generate variable list as input for other program
Date   Sun, 10 Jan 2010 01:24:55 -0800 (PST)

--- On Sun, 10/1/10, Joseph Coveney wrote:
> Try an approach like that illustrated below.
> 
> ============begin do-file==============
> 
> version 11.0
> 
> clear *
> set more off
> 
> program define sender, rclass
>     version 11.0
>     syntax
> 
>     local variable_list
>     foreach var of varlist _all {
>         capture confirm
> numeric variable `var'
>         if (!_rc) {
>            
> local variable_list `variable_list' `var'
>         }
>         else {
>            
> continue
>         }
>     }
> 
>     return local varlist `variable_list'
> end
> 
> program define receiver
>     version 11.0
>     syntax varlist
> 
>     summarize `varlist'
> 
>     display in smcl as text _newline(2)
> "`varlist'"
> end
> 
> sysuse auto
> 
> sender
> receiver `r(varlist)'
> 
> exit
> 
> ============end do-file==============


The program -sender- can be replaced by the line -ds, has(type numeric)-,
see: -help ds-.

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index