Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Macro questions.


From   adiallo5@worldbank.org
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Macro questions.
Date   Tue, 10 Aug 2004 18:25:03 -0400

Hi,

I have some questions about macros.

1/ I wonder how to count the number of variables in a macro.
I try the macro extended function (word count) but it doesn't work.
For example, if I have:
local myvars "var1 var2 var3 var4"
then `myvars' contains 4 variables.
But I do not know how to create a macro that contains the value 4.

2/ Suppose several datasets containing the same variable floor indexed
1, 2, 3, etc.... Floor* number varies with datasets.
I want to create the macro myfloor
local myfloor "floor*"
but then, I do not know how to create the macro containing the number of floor
as in question 1.

3/ How to work "inside" macros?
   suppose you have the following: local "var1 var2 var3 .....varN"
   suppose later in your dofile you want to do some tables on only - say 20-
variables of  the macro.
  Is it possible to just choose them (perhaps by specifying their position IN
the macro)
  without creating other (sub)macros?

4/ Finally my last question is how to merge/append several datasets?
    Suppose you have :
   local mydata "data1 data2 data3 data4 data5"
   foreach if i of local mydata {
       foreach j of local mydata {
         append `i' using `j'
      }
   }

How to avoid data1 being appended twice?

Best regards.
Amadou.



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