Hello,
I'm attempting to add " (real)" to the end of the label of a group variables. So if for example, a variable has the label "Example", it will become "Example (real)"
The following code already does this successfully for the variables vv1 vv2 vv3.
However, variable labels can't be longer than 80 characters, which becomes a problem for some of my variables as their labels are already close to this limit and adding " (real)" goes over it, resulting in nothing happening for those variables when I run the above loop.
My desired solution would be to add an extra step where for labels with length superior to 73, it would only keep the first keep those first 73 characters, making space for the 7 characters in " (real)". This is something that I'm not being able to do, and thus I ask for your help. I'm also open to other solutions if you can think of something better.
Thanks very much for your time.
Hélder Costa
I'm attempting to add " (real)" to the end of the label of a group variables. So if for example, a variable has the label "Example", it will become "Example (real)"
The following code already does this successfully for the variables vv1 vv2 vv3.
Code:
foreach v of vv1 vv2 vv3 { local l`v' : variable label `v' if `"`l`v''"' == "" { local l`v' "`v'" } } foreach v of var vv1 vv2 vv3 { label var `v' "`l`v'' (real)" }
My desired solution would be to add an extra step where for labels with length superior to 73, it would only keep the first keep those first 73 characters, making space for the 7 characters in " (real)". This is something that I'm not being able to do, and thus I ask for your help. I'm also open to other solutions if you can think of something better.
Thanks very much for your time.
Hélder Costa
Comment