Hi there, I was hoping you could help me to assign variable labels using the values of a variable within a different dta file.
Here are the example dta files:
I am trying to label the variables seq1, seq2 and seq3 in seqdata.dta using the variable targetfullname in seqlabels.dta. Below I have code where I am trying to order the variables in seqdata.dta so that I am then able to label, however, I get the following error: factor-variable and time-series operators not allowed
I then planned to label the var using the local `names', I would be grateful for some help with this!
Thank you so much in advance!
Very best,
Liz
Here are the example dta files:
Code:
clear input sampleid seq1 seq2 seq3 1 . . . 2 . . . 3 . . . end save seqdata.dta, replace clear input str4 aptname str5 targetfullname seq1 name1 seq2 name2 seq3 name3 end save seqlabels.dta, replace
Code:
use seqlabels.dta, clear sort aptname levelsof aptname, local(seqs) clean levelsof targetfullname, local(names) clean use seqdata.dta, clear order sampleid `seqs'
Thank you so much in advance!
Very best,
Liz
Comment