lbl_list_long_var_lbl
Title
lbl_list_long_var_lbl - List variables whose variable label is longer than the desired character length.
Syntax
lbl_list_long_var_lbl , [maxlen(integer) varlist(varlist)]
options | Description |
---|---|
maxlen(integer) | Maximum character length allowed. |
varlist(varlist) | Restrict the scope of variables to consider |
Description
When variable labels are too long, Stata truncates them to the first 80 characters of the string provided. This situation might arise for data exported from Survey Solutions. If provided, Survey Solutions uses the Variable label field in Designer, whose length is capped at 80 characters (in line with Stata’s limits). If no label is specified in that field, Survey Solutions uses the Question text field, whose length maximum length is 2,000 characters. In the latter case, Survey Solutions uses the first 80 characters of the question text as its label.
To detect possible cases of truncation, data producers can check the length of each variable label individually (e.g., local var_lbl : variable label my_var; local lbl_len : ustrlen local var_lbl
).
However, there is no base Stata operation for doing so in batch.
This command provides just such a tool.
By default, the command take the maximum length to be Stata’s maximum length for labels: 80 characters. If desired, the command can specify an alternative length through the maxlen(integer) option.
Options
maxlen(integer) sets the maximum length of variable labels, beyond which a variable is listed by this command.
varlist(varlist) restricts the scope of the search to the user-provided variable list. By default, the command searches for matches in all variables in memory. With varlist(), the scope of the search can be narrowed.
Examples
* create set of variables
gen var1 = .
gen var2 = .
gen var3 = .
gen var4 = .
gen var5 = .
* apply variables
label variable var1 "Short label"
label variable var2 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
label variable var3 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
label variable var4 "Another short label"
label variable var5 "你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好"
* list variables with longer than the default max length (80 characters)
lbl_list_long_var_lbl
* list variables with longer than the user-specified max length
lbl_list_long_var_lbl, maxlen(12)
Feedback, bug reports and contributions
Read more about the commands in this package at https://github.com/lsms-worldbank/labeller.
Please provide any feedback by opening an issue at https://github.com/lsms-worldbank/labeller/issues.
PRs with suggestions for improvements are also greatly appreciated.