Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st:cumulative the looped results after -foreach-


From   Amanda Fu <mandy.fu1@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st:cumulative the looped results after -foreach-
Date   Sat, 18 Dec 2010 11:25:50 -0500

Dear Statalisters,

I  wondered how to easily indicate the list of all the results from a
loop without typing one by one.  It is kind of like cumulative the
looped results. An example is as following.
-------------------------------------
local var A B C D E F G X Y Z                    // create 7 dummy
variables for each variable in `var'
foreach v of var {
foreach i of a b c d e f g  {
   g  `var'`i'=.
      replace `var'`i'=1 if group==`i'
      replace  var'`i'=0 if group~=`i'
}
}
end                                                              //
how to indicate all the dummy variables created without typing all of
them out
----------------------------------
My question is : How to indicate the following list of variables
easily without typing each of them?
Aa Ab .....Ag Ba......Zg                 (variables are separated with blank)

Thank you!
Sincerely,
Amanda
*
*   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   |   Site index