Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

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

From |
Daniele Pacifico <danielepacifico@yahoo.it> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Problems with:"drawnorm "$varlist"_1, mean(b1) cov(V1) |

Date |
Thu, 9 Sep 2010 14:52:37 +0000 (GMT) |

Dear Statalist, I have a problem with the following loop: global varlist "x y z" forvalues c=1/5{ drawnorm "$varlist"_`c', mean(b`c') cov(V`c') } Where b`c' is a 1x5 vector and V`c' is a 5x5 matrix.. With the previous loop I would like to create these new set of variables: x_1, y_1, z_1 with mean b_1 and var-cov V_1; x_2, y_2, z_2 with mean b_2 and var-cov V_2; etc.. In other words, I would like to create 3x5 new variables using the same name of the tree main variables (x,y,z) but adding _`c' at the end of each of them... Of course, I can always write: forvalues c=1/5{ drawnorm x_`c' y_`c' z_`c' , mean(b`c') cov(V`c') } and get what I want.. However, I need to find a way that allows me to change automatically the number and the name of the variables in varlist.. Any advise about the right way of constructing this type of loop? Thanks in advance, Daniele Pacifico * * 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/

**Follow-Ups**:**Re: st: Problems with:"drawnorm "$varlist"_1, mean(b1) cov(V1)***From:*Jeph Herrin <stata@spandrel.net>

**Re: st: Problems with:"drawnorm "$varlist"_1, mean(b1) cov(V1)***From:*Maarten buis <maartenbuis@yahoo.co.uk>

**Re: st: Problems with:"drawnorm "$varlist"_1, mean(b1) cov(V1)***From:*Stas Kolenikov <skolenik@gmail.com>

- Prev by Date:
**Re: st: AW: STATA Estimation** - Next by Date:
**Re: st: Problems with:"drawnorm "$varlist"_1, mean(b1) cov(V1)** - Previous by thread:
**st: merge with condition or vlookup with not-exact-match** - Next by thread:
**Re: st: Problems with:"drawnorm "$varlist"_1, mean(b1) cov(V1)** - Index(es):