Please how can I put the different tables below in the same excel sheet. Thanks.
Code:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str5 agerange byte(c1 c4) "45-59" 2 0 "18-29" 2 5 "30-44" 1 0 "18-29" 2 77 "30-44" 2 77 "18-29" 2 0 "60-69" 1 77 "30-44" 2 12 "30-44" 2 15 "45-59" 2 7 "60-69" 2 77 "45-59" 2 5 "30-44" 1 15 "30-44" 1 15 "30-44" 2 77 "18-29" 2 12 "30-44" 2 19 "30-44" 1 12 "18-29" 2 12 "30-44" 2 12 "18-29" 1 9 "45-59" 2 10 "18-29" 2 12 "45-59" 1 16 "60-69" 2 77 "18-29" 1 16 "45-59" 1 12 "30-44" 2 15 "30-44" 2 19 "18-29" 1 15 "30-44" 1 17 "30-44" 1 15 "18-29" 1 14 "30-44" 2 77 "18-29" 1 11 "60-69" 2 15 "30-44" 2 17 "30-44" 2 6 "30-44" 2 19 "30-44" 2 12 "30-44" 1 21 "30-44" 2 12 "30-44" 1 25 "30-44" 1 12 "18-29" 2 12 "18-29" 2 12 "60-69" 1 14 "18-29" 1 1 "" 1 77 "18-29" 2 19 "60-69" 1 77 "60-69" 1 77 "18-29" 1 12 "45-59" 1 14 "18-29" 1 13 "45-59" 2 0 "18-29" 1 12 "18-29" 2 0 "30-44" 2 0 "30-44" 1 12 "45-59" 1 77 "45-59" 2 7 "30-44" 1 12 "18-29" 1 12 "30-44" 2 15 "18-29" 1 8 "18-29" 1 14 "30-44" 2 6 "18-29" 2 18 "45-59" 2 77 "18-29" 2 18 "30-44" 2 12 "30-44" 2 6 "60-69" 1 6 "45-59" 2 0 "18-29" 2 77 "30-44" 2 0 "30-44" 1 18 "30-44" 2 16 "18-29" 1 15 "30-44" 1 12 "18-29" 1 12 "30-44" 2 12 "45-59" 1 18 "45-59" 2 14 "30-44" 2 12 "30-44" 1 14 "30-44" 1 17 "30-44" 2 11 "30-44" 1 16 "18-29" 2 12 "18-29" 1 23 "30-44" 2 17 "30-44" 2 17 "30-44" 1 0 "18-29" 2 9 "45-59" 2 20 "30-44" 1 18 "30-44" 2 14 "45-59" 1 15 end label values c1 labels2 label def labels2 1 "Male", modify label def labels2 2 "Female", modify
Code:
lab var agerange "Age Group (years)" lab var c1 "Age group and sex of respondents" lab var c4 "Mean number of years of education" qui:table (agecat) (c1), statistic(freq) statistic(percent) nformat(%5.0f freq) nformat(%5.1f percent) sformat("(%s%%)" freq percent) qui:collect composite define freqperc_c1 = frequency percent qui:collect label levels result freqperc_c1 "n (%)" collect layout (agecat) (c1#result[freqperc_c1]) collect export AFF.xlsx, sheet(Tables, replace) modify qui:table (agecat) (c1), statistic(freq) statistic(mean c4) nformat(%5.0f freq) nformat(%5.1f mean) sformat("(%s)" freq mean) qui:collect composite define freqperc_c4 = frequency mean qui:collect label levels result freqperc_c4 "n (mean)" collect layout (agecat) (c1#result[freqperc_c4]) collect export AFF.xlsx, sheet(Tables) modify
Code:
Results: Age group and sex of respondents ---------------------------------------------------------------------- | Male Female Total | n (%) n (%) n (%) ------------------+--------------------------------------------------- Age Group (years) | 18-29 | 3,226 (13.1%) 4,320 (17.6%) 7,546 (30.7%) 30-44 | 4,056 (16.5%) 4,693 (19.1%) 8,749 (35.6%) 45-59 | 2,760 (11.2%) 2,763 (11.2%) 5,523 (22.4%) 60-69 | 1,460 (5.9%) 1,330 (5.4%) 2,790 (11.3%) Total | 11,502 (46.7%) 13,106 (53.3%) 24,608 (100.0%) ---------------------------------------------------------------------- Mean number of years of education ------------------------------------------------------------------ | Male Female Total | n (mean) n (mean) n (mean) ------------------+----------------------------------------------- Age Group (years) | 18-29 | 3,226 (14.2) 4,320 (14.2) 7,546 (14.2) 30-44 | 4,056 (15.0) 4,693 (15.2) 8,749 (15.1) 45-59 | 2,760 (15.5) 2,763 (14.5) 5,523 (15.0) 60-69 | 1,460 (16.3) 1,330 (16.7) 2,790 (16.5) Total | 11,502 (15.1) 13,106 (14.9) 24,608 (15.0) ------------------------------------------------------------------
Comment