Statalist


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

st: Question: postfile with variable number variables


From   Eve CORDA <eve.corda@inserm.fr>
To   statalist@hsphsun2.harvard.edu
Subject   st: Question: postfile with variable number variables
Date   Fri, 03 Apr 2009 15:08:58 +0200

Dear all,

I would like to create a new file using the postfile command but the number of variables in the output file is not constant. More specifically, my program might look like that:

local variable_list "var1 var2 var3"
local no_var: word count `variable_list'
postfile postname `variable_list' using filename, replace
forvalues i=1(1)`no_var'{
   local var`i'=`i'
}
post postname (`var1') (`var2') (`var3')
postclose postname

My problem is that the variable_list macro does not have a constant number of elements. Do you know how I can write the post postname command to take this into account?

Thank you very much fo any help.

Best wishes

Eve Corda

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