Hello statalisters,
I have a do file set up which includes the following commands.
Please note $year1, $year2 and $siteterm are predetermined
use S:\stata\registration_stata.dta, clear
keep if year>=$year1
keep if year<=$year2
keep if sex==1
keep if siteterm=="$siteterm"
drop icdcode sex ha siteterm network
sort year
collapse (sum) age0 ages1to4 ages5to9 ages10to14 ages15to19
ages20to24 ages25to29 ages30to34 ages35to39 ages40to44 ages45to49 ages50to54
ages55to59 ages60to64 ages65to69 ages70to74 ages75to79 ages80to84 ages85plus
total , by(year)
xpose, clear varname
cd "S:\stata\"
Please imagine that year1 was specified as 1996 and year2 specified as 1998,
then we would be left with a dataset as follows
<<...>>
and I wish to save this as a matrix using
mkmat v1 v2 v3, matrix(males)
giving us a matrix labelled males:
1996 1997 1998
65 55 55
51 42 53
46 43 49
My problem is year1 and year2 can take any value form 1979 to 2000 and thus
the command line above would obviously only keep the first three specified
years. For example running all of the above for year1=1987 and year2=1993
would give us a dataset as follows.
<<...>>
But leaves a matrix labelled males as:
1987 1988 1989
65 49 42
44 40 40
41 30 29
Does anybody have any ideas what I could use instead of the "v1 v2 v3" to
cover any eventuality.
Thank you for your time,
Christopher D Fergusson
*
* 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/