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

From |
Eve CORDA <eve.corda@inserm.fr> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Question: postfile with variable number variables |

Date |
Tue, 07 Apr 2009 14:41:12 +0200 |

Dear all,

Best wishes Eve Eve, I saw your message on Statalist regarding -post- with a variable number of variables. Your code was close to having everything it needed. The only thing left to do is to build up a macro containing _all_ of the values you wish to post, rather than building up separate macros for each item you wish to post. Try the following, and if it works for you, perhaps we can report back to Statalist that this is what was needed in case anyone else is interested in a similar solution in the future: local variable_list "var1 var2 var3" local no_var: word count `variable_list' postfile postname `variable_list' using filename, replace local to_post // make sure to_post is empty just to be safe forvalues i=1(1)`no_var'{ local topost "`to_post' (`i')" } post postname `to_post' postclose postname The above code will put the following in to_post at each of the three loop iterations: iteration 1: (1) iteration 2: (1) (2) iteration 3: (1) (2) (3) Then, when you call -post-, to_post will be substituted in place to make the command post postname `to_post' post postname (1) (2) (3) Sincerely, Alan Riley StataCorp LP Vice President of Software Development ariley@stata.com 979-696-4600 979-696-4601 (fax) http://www.stata.com/ * * 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/

- Prev by Date:
**Re: st: non-nested random effects** - Next by Date:
**st: RE: Re: local macro with if qualifier** - Previous by thread:
**Re: st: Question: postfile with variable number variables** - Next by thread:
**st: Re: texdoc** - Index(es):

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