Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Accessing the value of the sort variable in a byable program


From   "Scott Merryman" <[email protected]>
To   <[email protected]>
Subject   st: RE: Accessing the value of the sort variable in a byable program
Date   Wed, 15 Nov 2006 19:24:36 -0600

Would it be easier to use -levelsof- and -foreach-?

Something like this:

levelsof subject, local(levels)
foreach l of local levels {
	disp "Total Enrollment of subject `l'"
	tab newterm if subject == `l'
	disp " "
	disp "Total Enrollment by Credit Status for subject `l'"
	tab regcred if subject == `l'
}

Scott
	

> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Jackson, Catherine A.
> Sent: Wednesday, November 15, 2006 6:24 PM
> To: [email protected]
> Cc: Jackson, Catherine A.
> Subject: st: Accessing the value of the sort variable in a byable program
> 
> I'm working on a program that will generate a series of tables for
> various academic departments.  I want each department's tables to be
> together so I've written a fairly generalizable "byable" program as
> follows:
> 
> >program define neat, byable(recall)
> >      version 9.2
> >
> >      marksample touse
> >
> >      display "Total enrollment"
> >      tab newterm if `touse'
> >
> >      display "Total enrollment by credit status"
> >      tab regcred if `touse'
> >
> >      end
> >
> >sort subject
> >by subject: neat
> 
> I'd like to enhance the output by displaying the current subject_value
> in the title of each table (the current subject_value is printed at the
> top of each series of tables automatically).  I've tried a variety of
> statements including:
> >display subject "  subject"
> >display `_byvars' "  _byvars"
> However, I always get the first subject_value, rather than the current
> subject_value as indicated by the -> automatic heading.
> 
> Does anyone know how I can capture the current subject value and print
> it out as part of the program?
> 
> Any suggestions would be greatly appreciated!
> Thanks.
> Catherine


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