Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: construct a loop


From   Nikolaos Pandis <[email protected]>
To   [email protected]
Subject   Re: st: construct a loop
Date   Sat, 19 Feb 2011 23:32:39 -0800 (PST)

Dear Daniel,

Many thanks.
I am not sure I can follow the code and make it work.
Let's say i have 2 variables
gender:2 levels
agegroup: 3 levels
How would I fit those in your code?

Many thanks,
Nick

--- On Sun, 2/20/11, Daniel Klein <[email protected]> wrote:

> From: Daniel Klein <[email protected]>
> Subject: Re: st: construct a loop
> To: [email protected]
> Date: Sunday, February 20, 2011, 1:58 AM
> Nick,
> 
> although I do (did) not know the -stmh- command, I think
> the following short program should do what you are asking
> for.
> 
> /*Code*/
> 
> cap prog drop foo
> 
> prog foo
>    syntax varlist(numeric)
>    foreach var of loc varlist {
>       qui levelsof `var' ,loc(lvls)
>          forval j = 2/`: word
> count `lvls'' {
>             loc i = `j' - 1
>            forval k
> = 1/`i' {
>               stmh
> ,c(`: word `j' of `lvls'',`: word `k' of `lvls'')
>            }
>      }
>    }
> end
> 
> /*end*/
> 
> Best
> Daniel
> -- 
> NEU: FreePhone - kostenlos mobil telefonieren und
> surfen!       
>     
> Jetzt informieren: http://www.gmx.net/de/go/freephone
> *
> *   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/
> 


      

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index