Hi Everyone,
I am currently working with a dataset with ~800 variables across 3 waves (12, 13, and 14). I have been attempting to reshape the dataset from wide to long. However, this seems to remove all the variable labels. I have attempted using the reshape8 command to preserve the labels, however, this has not worked. With the complete dataset (i.e., 800 variables), I am getting the error that the expression is too long. However, if I use a smaller dataset like the one provided below, the reshape8 command does go through although the labels are not preserved.
Here is the code I used:
Here is the error:
Any help/input at all would be greatly appreciated!
I am currently working with a dataset with ~800 variables across 3 waves (12, 13, and 14). I have been attempting to reshape the dataset from wide to long. However, this seems to remove all the variable labels. I have attempted using the reshape8 command to preserve the labels, however, this has not worked. With the complete dataset (i.e., 800 variables), I am getting the error that the expression is too long. However, if I use a smaller dataset like the one provided below, the reshape8 command does go through although the labels are not preserved.
Here is the code I used:
Code:
unab stubs: *12 *13 *14 forvalues i = 12/14 { local stubs: subinstr local stubs "`i'" "", all local stubs: subinstr local stubs "`i'" "", all } local stubs: list uniq stubs macro list _stubs reshape8 long `stubs', i(hhidpn) j(wave)
(note: j = 12 13 14)Here is a sample of my data, if helpful:
expression too long
r(130);
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long hhidpn byte(mstat_w12 mstat_w13 mstat_w14 mstath_w12 mstath_w13 mstath_w14 mstatf_w12 mstatf_w13 mstatf_w14 cesd_w12 cesd_w13 cesd_w14 cesdm_w12 cesdm_w13 cesdm_w14) int radtimtdth long sswrer_w13 1010 . . . . . . . . . . . . . . . 10 . 2010 . . . . . . . . . . . . . . . 20 . 3010 . . . . . . . . . . . . . . . 13 . 3020 7 . . 7 . . 0 . . 0 . . 0 . . 17 . 10001010 8 8 . 8 8 . 0 0 . 0 0 . 0 0 . .x .c 10003020 . . . . . . . . . . . . . . . 21 . 10003030 5 7 7 5 7 7 5 5 0 1 1 1 0 0 0 .x 121100 10004010 . . . . . . . . . . . . . . . 15 . 10004040 7 7 1 7 7 1 0 0 0 0 0 0 0 0 0 .x .c 10013010 5 . . 5 . . 0 . . 3 . . 0 . . 19 . 10013040 5 5 5 5 5 5 0 0 0 0 2 0 0 0 0 .x .c 10038010 1 1 1 1 1 1 0 0 0 1 1 0 0 0 0 .x .c 10038040 1 1 1 1 1 1 0 0 0 1 0 2 0 0 0 .x .c 10050010 7 7 . 7 7 . 0 0 . 0 0 . 0 0 . .x .c 10059020 1 1 1 1 1 1 0 0 0 0 1 0 0 0 0 .x .c 10059030 1 1 1 1 1 1 0 0 0 0 1 0 0 0 0 .x .c 10063010 5 5 . 5 5 . 5 0 . 0 1 . 0 0 . 14 .c 10075020 7 7 7 7 7 7 0 0 0 0 0 0 0 0 0 .x .c 10075030 . . . . . . . . . . . . . . . 17 . 10083010 . . . . . . . . . . . . . . . 19 . 10083020 . . . . . . . . . . . . . . . 83 . 10090010 . . . . . . . . . . . . . . . 4 . 10094010 . . . . . . . . . . . . . . . 13 . 10097010 . . . . . . . . . . . . . . . 10 . 10097040 7 7 . 7 7 . 0 0 . 0 0 . 0 0 . .x .c 10099010 7 7 . 7 7 . 0 0 . .s 0 . 8 0 . 13 .c 10106010 1 1 1 1 1 1 0 0 0 1 0 1 0 0 0 .x .c 10106020 1 1 1 1 1 1 0 0 0 0 4 1 0 0 0 .x .c 10109020 . . . . . . . . . . . . . . . 28 . 10109030 7 7 7 7 7 7 0 0 0 2 1 3 0 0 0 .x .c 10114010 . . . . . . . . . . . . . . . .x . 10124010 . . . . . . . . . . . . . . . .x . 10124011 . . . . . . . . . . . . . . . .x . 10147010 5 7 5 5 7 5 0 5 5 4 7 5 0 0 0 23 .c 10155010 . . . . . . . . . . . . . . . .x . 10196010 . . . . . . . . . . . . . . . 25 . 10206010 . . . . . . . . . . . . . . . 19 . 10210010 . . . . . . . . . . . . . . . 22 . 10210020 7 7 . 7 7 . 0 0 . 1 .s . 0 8 . .x .c 10217010 . . . . . . . . . . . . . . . 11 . 10225010 8 . . 8 . . 0 . . 4 . . 0 . . 56 . 10237020 . . . . . . . . . . . . . . . .x . 10237030 . . . . . . . . . . . . . . . .x . 10240010 . . . . . . . . . . . . . . . 12 . 10257010 . . . . . . . . . . . . . . . .x . 10281010 1 1 1 1 1 1 0 0 0 .s .s .s 8 8 8 .x .c 10281020 1 1 1 1 1 1 0 0 0 4 1 0 0 0 0 .x .c 10299010 3 5 5 5 5 5 0 0 0 0 0 0 0 0 0 .x .c 10299011 .m . . 5 . . 0 . . 6 . . 0 . . .x . 10299012 . . . . . . . . . . . . . . . .x . 10325010 . . . . . . . . . . . . . . . 68 . 10325020 7 7 7 7 7 7 0 0 0 0 0 2 0 0 0 .x .c 10346010 . . . . . . . . . . . . . . . 14 . 10372010 8 8 8 8 8 8 0 0 0 3 3 5 0 0 0 .x .c 10378010 . . . . . . . . . . . . . . . .x . 10394010 . . . . . . . . . . . . . . . .x . 10394040 . . . . . . . . . . . . . . . 15 . 10395010 . . . . . . . . . . . . . . . 22 . 10395020 7 7 7 7 7 7 0 0 0 1 2 .s 0 0 8 12 .c 10397010 7 7 7 7 7 7 0 0 0 1 0 0 0 0 0 .x .c 10397040 . . . . . . . . . . . . . . . 7 . 10404010 7 7 7 7 7 7 0 0 0 0 0 0 0 0 0 .x .c 10405010 . . . . . . . . . . . . . . . .x . 10405040 . . . . . . . . . . . . . . . .x . 10410010 . . . . . . . . . . . . . . . 31 . 10414020 . . . . . . . . . . . . . . . .x . 10414030 . . . . . . . . . . . . . . . .x . 10433010 7 7 . 7 7 . 0 0 . 1 3 . 0 0 . 7 .c 10433040 . . . . . . . . . . . . . . . 15 . 10451010 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 .x .c 10451020 1 1 1 1 1 1 0 0 0 2 7 3 0 0 0 .x .c 10453010 1 1 1 1 1 1 0 0 0 0 .s .s 0 8 8 12 .c 10453020 1 1 1 1 1 1 0 0 0 1 0 4 0 0 0 .x .c 10458020 1 1 1 1 1 1 0 0 0 1 2 3 0 0 0 .x .c 10458030 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 .x .c 10460010 . . . . . . . . . . . . . . . 21 . 10465010 . . . . . . . . . . . . . . . .x . 10465020 . . . . . . . . . . . . . . . 34 . 10468010 . . . . . . . . . . . . . . . 26 . 10468020 . . . . . . . . . . . . . . . 25 . 10475010 5 5 . 5 5 . 0 0 . 6 .s . 0 8 . 11 .c 10475011 . . . . . . . . . . . . . . . 37 . 10477010 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 .x .c 10477020 1 1 1 1 1 1 0 0 0 2 1 2 0 0 0 .x .c 10481010 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 .x .c 10481020 1 1 1 1 1 1 0 0 0 2 2 1 0 0 0 .x .c 10482010 5 . . 5 . . 0 . . 3 . . 0 . . .x . 10533010 . . . . . . . . . . . . . . . 6 . 10533011 1 1 1 1 1 1 0 0 0 3 0 1 0 0 0 .x .c 10533020 . . . . . . . . . . . . . . . .x . 10537010 1 2 2 1 2 2 0 0 0 1 .s .s 0 8 8 .x .c 10537011 1 2 2 1 2 2 0 0 0 2 4 5 0 0 0 .x .c 10546010 . . . . . . . . . . . . . . . 57 . 10556010 . . . . . . . . . . . . . . . 8 . 10565020 7 7 7 7 7 7 0 0 0 0 0 0 0 0 0 17 .c 10565030 . . . . . . . . . . . . . . . 21 . 10567010 . . . . . . . . . . . . . . . 23 . 10568010 . . . . . . . . . . . . . . . 11 . 10571010 7 7 7 7 7 7 0 0 0 8 4 5 0 0 0 .x .c 10571020 . . . . . . . . . . . . . . . 0 . end label values mstat_w12 MSTATUS label values mstat_w13 MSTATUS label values mstat_w14 MSTATUS label def MSTATUS 1 "1.married", modify label def MSTATUS 3 "3.partnered", modify label def MSTATUS 5 "5.divorced", modify label def MSTATUS 7 "7.widowed", modify label def MSTATUS 8 "8.never married", modify label def MSTATUS .m ".m=missing", modify label def MSTATUS 2 "2.married,spouse absent", modify label values mstath_w12 MSTATH label values mstath_w13 MSTATH label values mstath_w14 MSTATH label def MSTATH 1 "1.married", modify label def MSTATH 5 "5.divorced", modify label def MSTATH 7 "7.widowed", modify label def MSTATH 8 "8.never married", modify label def MSTATH 2 "2.married,spouse absent", modify label values mstatf_w12 MSTATF label values mstatf_w13 MSTATF label values mstatf_w14 MSTATF label def MSTATF 0 "0.no discrepancy", modify label def MSTATF 5 "5.othr dif unmarried ms", modify
Comment