Statalist The Stata Listserver


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

RE: st: RE: RE: manipulating string variables


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: RE: manipulating string variables
Date   Mon, 31 Jul 2006 17:59:46 +0100

You can do this, as experiment will show. 

Given 

global dem "age sex" 
global dem1 "age" 

you can set 

global reg1 "reg hours $dem" 

in which case -reg1- will contain 

"reg hours age sex" 

or you can set 

global reg1 "reg hours $dem1" 

in which case -reg1- will contain

"reg hours age" 

Trailing spaces can also be added as desired. 
Whichever definition is last in a session will
overwrite any previous ones. 

Nick 
[email protected] 

Jean Eid
 
> One more question regarding manipulating global macros. Is there a way
> to do the following
> global  reg1 "reg hours $dem ";
> where $dem is defined as
> 
> global dem "age sex";
> 
> and
> 
> global dem1 "age";
> 
> now I want to replace $dem with $dem1 in $reg1
> 
> All the solutions below do not work since stata attempts to 
> execute the
> global macro $dem when calling global macro $reg1.
> 

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