I have a fairly simple problem: All variables of my dataset have value labels (lblname1, lblname2, ..., lblname10.000). All values are labeled, except the missing code ".z". I want the missing code ".z" to have the label "label for .z" for all variables while keeping the existing value labels.
I can do this via:
Yet, I would have to do this for lblname1 to lblname10.000.
Instead of typing the above line 10.000 times, I tried to loop over the different label containers:
I don't get an error message, but the code doesn't seem to do anything.
My next try was like that:
This results in the error message: "invalid attempt to modify label"
What am I doing wrong?
Thank you very much in advance.
Andreas
I can do this via:
Code:
label define lblname1 .z "label for .z", add
Instead of typing the above line 10.000 times, I tried to loop over the different label containers:
Code:
qui label list foreach i in `r(names)'{ label define `i' .z "label for .z", add }
My next try was like that:
Code:
label dir // get all value label container names global lblnames "lblname1 lblname2 ... lblname10.000" // foreach i of global lblnames { lab def `i' .z "label for .z", add }
What am I doing wrong?
Thank you very much in advance.
Andreas
Comment