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

st: macro shift


From   [email protected]
To   [email protected]
Subject   st: macro shift
Date   Tue, 11 May 2004 14:03:39 -0600



I would like to use the 'svytab' command for a large number of items from a
questionnaire, and run these results for a large number of subpopulations
in my dataset.  This is a survey of high school students, and for each
item, I would like to run a table by sex and grade level.  The
subpopulations are the various school districts in the state.  Using 'macro
shift' I have written a program that will run 'svytab' for each item in the
questionnaire, but I would like to use 'macro shift' at the same time to
run the tables for each school district.

The variables from the questionnaire items are in a local macro called
'quest'.  (local quest q1 q2 q3 q4...).
Each school district is represented by a dichotomous variable, with a '1'
indicating a respondent from within the particular school district, and a
'0' indicating a student from a different school district.  The school
districts are in a local macro called 'district'.  (local district d1 d2 d3
d4....)
The output I want is a set of tables for each school district (subpop).

This is the program I am using to run the tables, without referring to
subpopulations:

program define xtab
   while `1' ~= "" {
    svytab sex `1', row per ci
    svytab grade `1', row per ci
    macro shift
 }
end

The command I use to run all the tables is:
xtab `quest'

So the question is, how do I get this program to run all of the tables for
each of the various subpopulations, without rewriting the program for each
of the subpopulations?

Thanks,
Dan


Dan Green
Social Indicator Epidemiologist
Office of Epidemiology
New Mexico Department of Health
1190 St. Francis Dr. N1311
PO Box 26110
Santa Fe, NM 87502-6110
Phone:  (505)476-1779
Fax:  (505)827-0013
[email protected]

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