Please how can I generate this type of table with the table command.

being trying to work out the code to no avail. thanks.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte(c1 c4) str5 agerange 2 0 "45-59" 2 5 "18-29" 1 0 "30-44" 2 77 "18-29" 2 77 "30-44" 2 0 "18-29" 1 77 "60-69" 2 12 "30-44" 2 15 "30-44" 2 7 "45-59" 2 77 "60-69" 2 5 "45-59" 1 15 "30-44" 1 15 "30-44" 2 77 "30-44" 2 12 "18-29" 2 19 "30-44" 1 12 "30-44" 2 12 "18-29" 2 12 "30-44" 1 9 "18-29" 2 10 "45-59" 2 12 "18-29" 1 16 "45-59" 2 77 "60-69" 1 16 "18-29" 1 12 "45-59" 2 15 "30-44" 2 19 "30-44" 1 15 "18-29" 1 17 "30-44" 1 15 "30-44" 1 14 "18-29" 2 77 "30-44" 1 11 "18-29" 2 15 "60-69" 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 "30-44" 2 12 "18-29" 2 12 "18-29" 1 14 "60-69" 1 1 "18-29" 1 77 "" 2 19 "18-29" 1 77 "60-69" 1 77 "60-69" 1 12 "18-29" 1 14 "45-59" 1 13 "18-29" 2 0 "45-59" 1 12 "18-29" 2 0 "18-29" 2 0 "30-44" 1 12 "30-44" 1 77 "45-59" 2 7 "45-59" 1 12 "30-44" 1 12 "18-29" 2 15 "30-44" 1 8 "18-29" 1 14 "18-29" 2 6 "30-44" 2 18 "18-29" 2 77 "45-59" 2 18 "18-29" 2 12 "30-44" 2 6 "30-44" 1 6 "60-69" 2 0 "45-59" 2 77 "18-29" 2 0 "30-44" 1 18 "30-44" 2 16 "30-44" 1 15 "18-29" 1 12 "30-44" 1 12 "18-29" 2 12 "30-44" 1 18 "45-59" 2 14 "45-59" 2 12 "30-44" 1 14 "30-44" 1 17 "30-44" 2 11 "30-44" 1 16 "30-44" 2 12 "18-29" 1 23 "18-29" 2 17 "30-44" 2 17 "30-44" 1 0 "30-44" 2 9 "18-29" 2 20 "45-59" 1 18 "30-44" 2 14 "30-44" 1 15 "45-59" end label values c1 labels2 label def labels2 1 "Male", modify label def labels2 2 "Female", modify
Code:
local c c1 c4 table (agerange) (), statistic(freq) statistic(percent, across(agerange)) nformat(%5.0f freq) nformat(%5.1f freq freq) sformat("(%s%%)" freq percent) foreach v of local c{ table (agerange) (`v'), statistic(freq) statistic(percent, across(agerange)) nformat(%5.0f freq) nformat(%5.1f freq freq) sformat("(%s%%)" freq percent) append collect continuous(c4, statistics(n mean)) collect composite define freqperc`v' = frequency percent collect label levels result freqperc`v' "n (%)" collect layout (agerange) (`v'#result[freqperc`v']) }
Comment