Originally posted by Trixi Bo
View Post
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input byte(SD14 SD17 SD18 SD5_h SD6_h) float LK_group byte(SD26 SD27) float hourly_wage_eb
1 1 2 3 4 3 1 1 .
2 1 2 3 4 4 3 3 .
3 1 2 2 1 4 3 3 12
1 1 2 3 1 . 1 1 .
5 1 1 3 4 1 1 3 42
3 1 2 3 1 3 1 1 29
3 1 2 1 2 1 1 3 27
2 1 2 3 4 4 3 3 14
3 3 2 3 4 1 1 3 8
3 1 2 3 4 1 1 3 20
3 1 2 3 4 1 1 3 33
3 1 2 3 4 1 1 3 12
3 1 2 3 4 3 1 1 .
3 1 2 3 4 5 5 80 .
3 1 2 3 3 1 1 3 37
3 1 2 2 1 3 1 1 15
3 1 2 3 4 3 1 1 33
4 1 1 2 4 4 3 3 .
5 1 2 3 4 1 1 3 7
3 3 1 1 4 1 1 3 32
end
label values SD14 SD14_mod
label def SD14_mod 1 "Ledig", modify
label def SD14_mod 2 "Lebe mit Partner bzw. Partnerin in einem Haushalt", modify
label def SD14_mod 3 "Verheiratet oder eingetragene Partnerschaft", modify
label def SD14_mod 4 "Verwitwet", modify
label def SD14_mod 5 "Geschieden", modify
label values SD17 SD17_mod
label def SD17_mod 1 "In Deutschland / Im Gebiet des heutigen Deutschlands", modify
label def SD17_mod 3 "Im Ausland / In einem anderen Land", modify
label values SD18 SD18_mod
label def SD18_mod 1 "Ja, mindestens ein Elternteil wurde ausserhalb von Deutschland geboren", modify
label def SD18_mod 2 "Nein, beide Elternteile wurden in Deutschland bzw. den ehemaligen deutschen Staatsgebieten geboren", modify
label values SD5_h SD5_hlbl_mod
label def SD5_hlbl_mod 1 "kein/HS/sonstiges", modify
label def SD5_hlbl_mod 2 "MR", modify
label def SD5_hlbl_mod 3 "FHR/Abi", modify
label values SD6_h SD6_hlbl_mod
label def SD6_hlbl_mod 1 "Lehre/Berufsausbildung/anderer berufsqual.", modify
label def SD6_hlbl_mod 2 "Meister- oder Technikerausbildung", modify
label def SD6_hlbl_mod 3 "Abschluss einer Berufsakademie oder einer dualen Hochschule", modify
label def SD6_hlbl_mod 4 "Uni/(F)H-Abschluss", modify
label values LK_group LK_grouplbl
label def LK_grouplbl 1 "(Solo-)Selbständig", modify
label def LK_grouplbl 3 "Hybride Beschäftigung", modify
label def LK_grouplbl 4 "Rente", modify
label def LK_grouplbl 5 "sonstiges/unklar", modify
label values SD26 SD26_mod
label def SD26_mod 1 "Erwerbstaetig", modify
label def SD26_mod 3 "In Rente", modify
label def SD26_mod 5 "Nicht erwerbstaetig", modify
label values SD27 SD27_mod
label def SD27_mod 1 "Ja, ein Beschaeftigungsverhaeltnis als Angestellter oder Beamter", modify
label def SD27_mod 3 "Nein, kein Beschaeftigungsverhaeltnis als Angestellter oder Beamter", modify
label def SD27_mod 80 "Ausgefiltert", modify
local fvars SD14 SD17 SD18 SD5_h SD6_h SD26 SD27
local cvars hourly_wage_eb
set seed 10232025
replace LK_group= runiformint(3,4)
collect clear
dtable `fvars' `cvars', ///
by(LK_group, nototals) ///
column(by(hide)) ///
sample(, place(seplabels) ) ///
continuous(, statistics(p50 mean)) ///
factor(, statistic(fvfrequency fvpercent)) ///
export("table1", as(docx) replace)
collect style cell var, font(Arial, size(10))
collect style cell result[p50 mean], nformat(%3.1f)
collect style cell result[fvpercent], nformat(%16.2fc)
collect style cell cell_type[column-header], font(Arial, size(11) color(black) bold)
collect style cell cell_type[row-header], halign(right)
collect style row stack, spacer
*CHECK TABLE DIMENSIONS
collect dims
*CHECK LEVELS OF DIMENSION "var"
collect levelsof var
collect preview
collect style cell var[`fvars']#cell_type[row-header], font(arial,bold)
collect preview
Code:
. *CHECK TABLE DIMENSIONS
. collect dims
Collection dimensions
Collection: DTable
-----------------------------------------
Dimension No. levels
-----------------------------------------
Layout, style, header, label
LK_group 2
_dtable_sample_dim 2
across 2
cmdset 1
colname 8
command 1
result 7
statcmd 4
var 10
Style only
border_block 4
cell_type 4
-----------------------------------------
. *CHECK LEVELS OF DIMENSION "var"
. collect levelsof var
Collection: DTable
Dimension: var
Levels: _N _hide SD14 SD17 SD18 SD5_h SD6_h SD26 SD27 hourly_wage_eb

Comment