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

From |
Steven Samuels <sjhsamuels@earthlink.net> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Loop over variables with svyset |

Date |
Wed, 19 Nov 2008 06:42:34 -0500 |

-Steven On Nov 19, 2008, at 5:35 AM, Daniel Schultz wrote:

Hej Stas.... this seemed to be a nice idea..... BUT.... For this kind of loop I need again for every variable every year. But unfortunately I don't have Variables for every year. Often only for the year 2002 and 2007, but also 2004 and 2006...you see what I mean? That is the biggest problem with this kind of loop. I think I have to split the data set even if this means more manually work. Best Daniel 2008/11/18 Stas Kolenikov <skolenik@gmail.com>:switch the order of the cycles, then. First loop over the variables, then over waves: forvalues k=1/999 { if `k' < 100 local k 0`k' if `k' < 10 local k 0`k' forvalues year=1/9 { * do whatever with variable Q`k'_0`year' } } On 11/18/08, Daniel Schultz <schultzd@tcd.ie> wrote:Hej Stas...... Your suggestion looked quite nice....but when I was testing it....it is doing first all of theVariables ofthe Year 2002 and than 2003 and so on.This is not exactly what I wanted....I need, that the svysetchangesevery time the Variable changed. Otherwise it would took me ages to bring all the variables together in one table (for one year). I am pretty sure it is doable, but I don't really know how. thanks for all your comments so far. Best Daniel ---------- Forwarded message ---------- From: Stas Kolenikov <skolenik@gmail.com> Date: 2008/11/18 Subject: Re: st: Loop over variables with svyset To: statalist@hsphsun2.harvard.edu how about this: * cycle over years forvalues year = 1/7 { * svyset for that yea svyset [pw=weight`year'] * cycle over the variables foreach x of varlist Q*_0`year' { svy: tab `x' } }You might also want to put some -quietly- and -noisily-statements inplaces, and may be figure out more of the TeX-related Statacommands.I am sure there is a way to put the tabulators & and \\ in properplaces from within Stata, but I've never done this with tables,onlywith estimates using -estout-. On 11/18/08, Daniel Schultz <schultzd@tcd.ie> wrote:Hej stata user....Maybe this question is too easy for you, but i am kicking itaroundsince a week ore so and couldn't find a proper solution.I have a dataset with 1200 variables of a survey. This surveywas heldover a couple of years. What I want to do is extracting acodebook ofthe dataset.Therefore every variable should be tabbed according to theirsurveyweight.The variable structure looks like this: Q0001_02 Q0001_07 Q0002_02 Q0002_03 Q0002_07 etc. Were the extension _0X indicates the year and the Prefix Qaaaa indicates the question number, which is the same over the years.Since I need the tables afterwards in an extrenal program(LaTex) allthe Variables should be proceed in the correct order.The problem is, that not every question was asked in everyyear, thatI really need to change the survey weight after every variableforthe new variable, depending on the extension. I tried a lot, but couldn't get a proper solution. For only one Variable the syntax should be as followed: svyset Q1170_02 *this is the weight variable svy:tab Q0001_02I tried to build a loop based on this, but all my tries didn'twork.Maybe one of you has an idea. That would be great.-- Stas Kolenikov, also found at http://stas.kolenikov.name Small print: I use this email account for mailing lists only. * * 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/-- Stas Kolenikov, also found at http://stas.kolenikov.name Small print: I use this email account for mailing lists only. * * 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/

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

**References**:**st: Loop over variables with svyset***From:*"Daniel Schultz" <schultzd@tcd.ie>

**Re: st: Loop over variables with svyset***From:*"Stas Kolenikov" <skolenik@gmail.com>

**Fwd: st: Loop over variables with svyset***From:*"Daniel Schultz" <schultzd@tcd.ie>

**Re: st: Loop over variables with svyset***From:*"Stas Kolenikov" <skolenik@gmail.com>

**Re: st: Loop over variables with svyset***From:*"Daniel Schultz" <schultzd@tcd.ie>

- Prev by Date:
**st: Inefficiency Models in Stata** - Next by Date:
**Re: st: Loop over variables with svyset** - Previous by thread:
**Re: st: Loop over variables with svyset** - Next by thread:
**Re: st: Loop over variables with svyset** - Index(es):

© Copyright 1996–2014 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |