Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Create a single table with information provided by xttab

    Hello,
    I have a longitudinal dataset (5 waves) and I´m using the command by sex wave, sort: xttab unsafe_dv to look for the number of individuals by sex that answer "yes" and n"o" to unsafe_dv. The result is a sequence of tables with the required information. Is it possible to have a single table with all the information?
    Thank y ou very much in advance.
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long(pidp pid) byte sex float wave byte unsafe_dv
     633352005  97406155 2 1 .
     683918177  31845606 2 1 .
    1157098895         . 1 1 .
     613171645  11302127 1 1 .
    1564745971         . 2 1 .
     408423647         . 2 1 .
     217620484         . 1 1 .
     749100247         . 1 1 .
     816146215         . 1 1 .
      69869329  16778111 1 1 .
    1156027211         . 1 1 .
    1293664651         . 1 1 0
     816133967         . 2 1 .
    1224690207         . 1 1 .
     435924205 118739549 1 1 .
    1293398767         . 1 1 0
      70127049  18346677 2 1 .
     422150129  94933499 2 1 .
     172978482         . 2 1 .
     748584884         . 2 1 .
    1360410051         . 2 1 .
     884158455         . 1 1 .
     544811247         . 2 1 .
     205445715         . 1 1 0
     136540609  14402327 2 1 .
      68740595         . 2 1 .
     204408011         . 2 1 .
    1292913939         . 1 1 .
    1225353282         . 2 1 .
     819397965  11892153 2 1 .
    1292189059         . 1 1 .
    1634644527         . 1 1 0
    1428384887         . 2 1 .
     410598287         . 2 1 .
     273079167         . 2 1 .
     683372129  33188769 1 1 .
     891554882         . 2 1 0
     749161451         . 2 1 .
     205319209  10468056 2 1 .
     292674725  96945303 2 1 .
     632578165  97933848 2 1 .
     205916249 123559545 1 1 .
     748897724         . 1 1 .
     274509211         . 2 1 .
     340758211         . 1 1 .
    1088426371         . 1 1 .
    1497121327         . 1 1 .
     544184975         . 1 1 .
     274468411         . 2 1 .
    1157062167         . 2 1 .
    1088819427         . 1 1 .
    1428334567         . 1 1 .
    1496956767         . 2 1 .
     544240047         . 1 1 .
    1428425011         . 1 1 .
    1496985327         . 1 1 .
    1020802411         . 1 1 .
      91810885 119261278 1 1 .
     680922091         . 1 1 .
    1566525543         . 2 1 0
     614299089  76816591 2 1 .
     478639091         . 2 1 .
     546802967         . 1 1 .
    1299195164         . 2 1 0
     416636284         . 2 1 .
    1566423527         . 2 1 0
      68843887         . 1 1 .
     342501727         . 2 1 .
    1428469887         . 1 1 0
     206572447         . 2 1 .
    1088120367         . 1 1 .
     136066649  10669582 2 1 .
     476701771         . 2 1 .
     639238089 118758578 2 1 .
    1224235295         . 2 1 .
    1497122007         . 2 1 .
     476030609  10340416 2 1 .
     409332811         . 1 1 .
     884806491         . 2 1 .
    1020639207         . 2 1 .
      70080125  16247396 2 1 .
    1564837771         . 2 1 .
     476413451         . 2 1 0
    1226738371         . 1 1 1
     884711295         . 2 1 .
    1088091127         . 2 1 .
     292852885  96931248 2 1 .
     410527567         . 1 1 .
     272930257  17421942 2 1 .
     354131765  96051728 2 1 .
     410569047         . 2 1 .
     170326562         . 1 1 .
     612083647         . 2 1 .
     572229593 119318571 2 1 .
    1157811527         . 2 1 0
     680359731         . 2 1 .
     340851369  16829611 2 1 .
      69177095         . 2 1 .
     204979207         . 1 1 .
     639380205 118898116 1 1 .
    end
    label values pid pid
    label values sex c_sex
    label def c_sex 1 "male", modify
    label def c_sex 2 "female", modify
    label values unsafe_dv c_unsafe_dv
    label def c_unsafe_dv 0 "no", modify
    label def c_unsafe_dv 1 "yes", modify

  • #2
    If you are using version 17,
    Code:
    table (wave sex) (unsafe_dv)

    Comment


    • #3
      I´m using version 16 but it worked. Thank you very much!

      Comment


      • #4
        In relation to the first question: Is it possible to have the results in the same table using several variables (unsafe1, unsafe2, unsafe3)? I tred the command table (wave sex) (unsafe1 unsafe2 unsafe3) but it didn´t work. I send an example of the dataset below.
        Thank you very much in advance.
        Code:
        * Example generated by -dataex-. For more info, type help dataex
        clear
        input long(pidp pid) byte sex float wave byte(unsafe1 unsafe2 unsafe3 unsafe4 unsafe5)
         476482809  13998242 1 5 0 0 0 0 0
         476482811         . 1 1 . . . . .
         410422845  11178973 1 1 . . . . .
         684705696         . 1 4 . . . . .
        1089041767         . 1 1 . . . . .
        1020389647         . 1 1 . . . . .
         546683287         . 1 4 . . . . .
         546337171         . 1 3 . . . . .
        1633304251         . 1 1 . . . . .
         885615011         . 1 4 0 0 0 0 0
         693837393  94555281 1 1 . . . . .
        1651883290         . 1 4 0 0 0 0 0
         342903734         . 1 4 . . . . .
         972345690         . 1 4 0 0 0 1 0
         816592971         . 1 1 . . . . .
         410492887         . 1 1 . . . . .
         136864291         . 1 1 . . . . .
        1226405859         . 1 2 0 0 0 1 0
         816941131         . 1 3 . . . . .
         952089099         . 1 4 . . . . .
         544211495         . 1 3 . . . . .
        1429125411         . 1 5 . . . . .
         477702727         . 1 3 0 0 0 0 0
          68383529  13280481 1 3 . . . . .
          71034853  91722071 1 3 . . . . .
         476495727         . 1 2 . . . . .
        1088748687         . 1 1 . . . . .
        1234934570         . 1 3 0 0 0 0 0
         558471085  94968195 1 1 . . . . .
         138154925  11564172 1 1 . . . . .
         952686811         . 1 4 . . . . .
         275957728         . 1 2 . . . . .
        1632845931         . 1 1 . . . . .
         613676213  35671246 1 1 . . . . .
         749284531         . 1 2 . . . . .
         136569851         . 1 4 . . . . .
         476497783         . 1 1 . . . . .
        1360282891         . 1 1 . . . . .
         476497783         . 1 3 . . . . .
         816975807         . 1 5 0 0 0 0 0
         204562371         . 1 3 . . . . .
        1497101611         . 1 1 . . . . .
         960078602         . 1 3 0 0 0 0 0
         953241687         . 1 3 . . . . .
         817123371         . 1 1 . . . . .
         136667087         . 1 2 . . . . .
         476504571         . 1 1 . . . . .
        1101076450         . 1 3 . . . . .
         545133571         . 1 1 . . . . .
        1428504571         . 1 2 . . . . .
         476505247         . 1 3 . . . . .
         749470165  16277627 1 4 . . . . .
        1632218287         . 1 2 . . . . .
        1428017007         . 1 1 . . . . .
         953139007         . 1 3 0 0 0 0 0
         544604531         . 1 1 . . . . .
        1020093171         . 1 3 . . . . .
         410131147         . 1 4 0 0 0 0 0
         163753525 118822969 1 3 . . . . .
         476131245  11205849 1 4 . . . . .
        1564567135         . 1 3 . . . . .
        1292182931         . 1 2 . . . . .
        1428964247         . 1 1 . . . . .
         476514771         . 1 1 . . . . .
          69003687         . 1 2 . . . . .
         341338935         . 1 1 . . . . .
        1158492887         . 1 1 0 0 0 0 0
         884398491         . 1 2 . . . . .
         476514779         . 1 2 . . . . .
        1564605211         . 1 1 . . . . .
          95740605 118812769 1 3 . . . . .
         885993775         . 1 2 0 0 0 0 0
         340214895         . 1 5 0 0 0 0 0
        1293752367         . 1 2 0 0 0 0 0
        1292937731         . 1 1 . . . . .
          69062859         . 1 5 0 0 0 0 0
        1428765011         . 1 2 . . . . .
         163809285 118544365 1 1 . . . . .
        1633269567         . 1 5 0 0 0 0 1
          68813979         . 1 5 0 0 0 0 0
         476529727         . 1 3 . . . . .
        1225584526         . 1 2 . . . . .
         749840767         . 1 1 0 0 0 0 0
         748669127         . 1 1 . . . . .
        1293804731         . 1 5 0 0 0 0 0
        1360196531         . 1 2 . . . . .
         545073731         . 1 5 0 0 0 0 0
         503911965 118726617 1 2 . . . . .
        1224558299         . 1 4 . . . . .
         748552863         . 1 5 0 0 0 0 0
         476533127         . 1 5 0 0 0 0 0
         693727169  94549478 1 2 . . . . .
         817337577  56546289 1 2 . . . . .
        1174094890         . 1 3 . . . . .
          70786653 163811504 1 4 . . . . .
         885111139         . 1 3 . . . . .
         272881967         . 1 1 . . . . .
         408391687         . 1 2 . . . . .
         273064211         . 1 3 . . . . .
         342016887         . 1 5 0 0 0 0 0
        end
        label values pid pid
        label values sex c_sex
        label def c_sex 1 "male", modify
        label values unsafe1 c_unsafe1
        label def c_unsafe1 0 "not mentioned", modify
        label values unsafe2 c_unsafe2
        label def c_unsafe2 0 "not mentioned", modify
        label values unsafe3 c_unsafe3
        label def c_unsafe3 0 "not mentioned", modify
        label values unsafe4 c_unsafe4
        label def c_unsafe4 0 "not mentioned", modify
        label def c_unsafe4 1 "Mentioned", modify
        label values unsafe5 c_unsafe5
        label def c_unsafe5 0 "not mentioned", modify
        label def c_unsafe5 1 "Mentioned", modify

        Comment


        • #5
          In version 17, it's quite simple:

          Code:
          table (wave sex) (var), statistic(fvfrequency unsafe*)
          // OR
          table (wave var) (sex), statistic(fvfrequency unsafe*)
          depending on which way you want the results laid out.

          But in version 16 or earlier, using only official StataCorp commands, I don't think you can generate that same kind of table. That said, there are a large number of user-written commands for creating tables and it may be that one of them can do this. I'm not very familiar with those commands and can't advise. I hope that somebody who knows one that fits the bill is following along and will intervene here.

          Comment


          • #6
            I am not especially clear what you want to see in your table, and naturally there are many possibilities. But groups from the Stata Journal will work in Stata 16.

            Here is a token example. I simplified the value labels; otherwise there is awkward wrap-around.

            Code:
            * Example generated by -dataex-. For more info, type help dataex
            clear
            input long(pidp pid) byte sex float wave byte(unsafe1 unsafe2 unsafe3 unsafe4 unsafe5)
             476482809  13998242 1 5 0 0 0 0 0
             476482811         . 1 1 . . . . .
             410422845  11178973 1 1 . . . . .
             684705696         . 1 4 . . . . .
            1089041767         . 1 1 . . . . .
            1020389647         . 1 1 . . . . .
             546683287         . 1 4 . . . . .
             546337171         . 1 3 . . . . .
            1633304251         . 1 1 . . . . .
             885615011         . 1 4 0 0 0 0 0
             693837393  94555281 1 1 . . . . .
            1651883290         . 1 4 0 0 0 0 0
             342903734         . 1 4 . . . . .
             972345690         . 1 4 0 0 0 1 0
             816592971         . 1 1 . . . . .
             410492887         . 1 1 . . . . .
             136864291         . 1 1 . . . . .
            1226405859         . 1 2 0 0 0 1 0
             816941131         . 1 3 . . . . .
             952089099         . 1 4 . . . . .
             544211495         . 1 3 . . . . .
            1429125411         . 1 5 . . . . .
             477702727         . 1 3 0 0 0 0 0
              68383529  13280481 1 3 . . . . .
              71034853  91722071 1 3 . . . . .
             476495727         . 1 2 . . . . .
            1088748687         . 1 1 . . . . .
            1234934570         . 1 3 0 0 0 0 0
             558471085  94968195 1 1 . . . . .
             138154925  11564172 1 1 . . . . .
             952686811         . 1 4 . . . . .
             275957728         . 1 2 . . . . .
            1632845931         . 1 1 . . . . .
             613676213  35671246 1 1 . . . . .
             749284531         . 1 2 . . . . .
             136569851         . 1 4 . . . . .
             476497783         . 1 1 . . . . .
            1360282891         . 1 1 . . . . .
             476497783         . 1 3 . . . . .
             816975807         . 1 5 0 0 0 0 0
             204562371         . 1 3 . . . . .
            1497101611         . 1 1 . . . . .
             960078602         . 1 3 0 0 0 0 0
             953241687         . 1 3 . . . . .
             817123371         . 1 1 . . . . .
             136667087         . 1 2 . . . . .
             476504571         . 1 1 . . . . .
            1101076450         . 1 3 . . . . .
             545133571         . 1 1 . . . . .
            1428504571         . 1 2 . . . . .
             476505247         . 1 3 . . . . .
             749470165  16277627 1 4 . . . . .
            1632218287         . 1 2 . . . . .
            1428017007         . 1 1 . . . . .
             953139007         . 1 3 0 0 0 0 0
             544604531         . 1 1 . . . . .
            1020093171         . 1 3 . . . . .
             410131147         . 1 4 0 0 0 0 0
             163753525 118822969 1 3 . . . . .
             476131245  11205849 1 4 . . . . .
            1564567135         . 1 3 . . . . .
            1292182931         . 1 2 . . . . .
            1428964247         . 1 1 . . . . .
             476514771         . 1 1 . . . . .
              69003687         . 1 2 . . . . .
             341338935         . 1 1 . . . . .
            1158492887         . 1 1 0 0 0 0 0
             884398491         . 1 2 . . . . .
             476514779         . 1 2 . . . . .
            1564605211         . 1 1 . . . . .
              95740605 118812769 1 3 . . . . .
             885993775         . 1 2 0 0 0 0 0
             340214895         . 1 5 0 0 0 0 0
            1293752367         . 1 2 0 0 0 0 0
            1292937731         . 1 1 . . . . .
              69062859         . 1 5 0 0 0 0 0
            1428765011         . 1 2 . . . . .
             163809285 118544365 1 1 . . . . .
            1633269567         . 1 5 0 0 0 0 1
              68813979         . 1 5 0 0 0 0 0
             476529727         . 1 3 . . . . .
            1225584526         . 1 2 . . . . .
             749840767         . 1 1 0 0 0 0 0
             748669127         . 1 1 . . . . .
            1293804731         . 1 5 0 0 0 0 0
            1360196531         . 1 2 . . . . .
             545073731         . 1 5 0 0 0 0 0
             503911965 118726617 1 2 . . . . .
            1224558299         . 1 4 . . . . .
             748552863         . 1 5 0 0 0 0 0
             476533127         . 1 5 0 0 0 0 0
             693727169  94549478 1 2 . . . . .
             817337577  56546289 1 2 . . . . .
            1174094890         . 1 3 . . . . .
              70786653 163811504 1 4 . . . . .
             885111139         . 1 3 . . . . .
             272881967         . 1 1 . . . . .
             408391687         . 1 2 . . . . .
             273064211         . 1 3 . . . . .
             342016887         . 1 5 0 0 0 0 0
            end
            label values pid pid
            label values sex c_sex
            label def c_sex 1 "male", modify
            
            label def yesno 0 no 1 yes 
            label val unsafe? yesno 
            
            groups wave sex unsafe?, sepby(wave) percent(wave sex)

            Code:
              +---------------------------------------------------------------------------------+
              | wave    sex   unsafe1   unsafe2   unsafe3   unsafe4   unsafe5   Freq.   Percent |
              |---------------------------------------------------------------------------------|
              |    1   male        no        no        no        no        no       2    100.00 |
              |---------------------------------------------------------------------------------|
              |    2   male        no        no        no        no        no       2     66.67 |
              |    2   male        no        no        no       yes        no       1     33.33 |
              |---------------------------------------------------------------------------------|
              |    3   male        no        no        no        no        no       4    100.00 |
              |---------------------------------------------------------------------------------|
              |    4   male        no        no        no        no        no       3     75.00 |
              |    4   male        no        no        no       yes        no       1     25.00 |
              |---------------------------------------------------------------------------------|
              |    5   male        no        no        no        no        no      10     90.91 |
              |    5   male        no        no        no        no       yes       1      9.09 |
              +---------------------------------------------------------------------------------+
            .
            A dot or bar chart could work as well or better than a table. The data example here leads to examples that are possibly misleading. To give people a better chance of suggesting alternatives you could show the results of say


            Code:
            contract wave sex unsafe1 unsafe2 unsafe3
            which as a dataset with no more than 80 observations could be shown comfortably here.

            Do you want to see joint distributions, or just marginal distributions?



            Comment


            • #7
              The commands are not working. I have stata 16. I just want to have a single table where I can see how many individuals answered "yes" or "no" to the questions represented by unsafe1 unsafe 2 unsafe 3 in each wave (waves 1 - 5).
              Thank you very much in advance.

              Comment


              • #8
                So, marginal not joint distributions are what you want? Better data example please.

                Comment


                • #9
                  Yes, marginal distributions. I send the example of the dataset below. Thank you very much

                  ​​​​​​
                  Code:
                  * Example generated by -dataex-. For more info, type help dataex
                  clear
                  input long(pidp pid) byte sex float wave byte(unsafe1 unsafe2 unsafe3 unsafe4 unsafe5 unsafe6 unsafe7 unsafe8 unsafe9 unsafe10 unsafe11 unsafe96 unsafe97)
                   409647647         . 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0
                  1634610527         . 2 1 0 0 0 0 0 0 0 0 0 0 0 1 0
                   952072767         . 1 1 . . . . . . . . . . . . .
                   341491247         . 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0
                   748431807         . 2 1 . . . . . . . . . . . . .
                   708011929 119124416 2 1 . . . . . . . . . . . . .
                  1360308727         . 1 1 . . . . . . . . . . . . .
                  1225350487         . 1 1 . . . . . . . . . . . . .
                   544259091         . 1 1 . . . . . . . . . . . . .
                   614078773 101104774 2 1 . . . . . . . . . . . . .
                    68615407         . 1 1 . . . . . . . . . . . . .
                   816091127         . 2 1 . . . . . . . . . . . . .
                   272061207         . 1 1 . . . . . . . . . . . . .
                   749772085  16283228 2 1 . . . . . . . . . . . . .
                  1360784047         . 1 1 . . . . . . . . . . . . .
                   340041485  10485937 1 1 . . . . . . . . . . . . .
                  1225351167         . 2 1 . . . . . . . . . . . . .
                   681248495         . 2 1 . . . . . . . . . . . . .
                   615472765  13796682 1 1 . . . . . . . . . . . . .
                  1632425011         . 2 1 . . . . . . . . . . . . .
                  1227788364         . 1 1 . . . . . . . . . . . . .
                   544743927         . 1 1 . . . . . . . . . . . . .
                   885260051         . 1 1 . . . . . . . . . . . . .
                   218308565  95300988 2 1 . . . . . . . . . . . . .
                   748062567         . 2 1 . . . . . . . . . . . . .
                   340541979         . 1 1 . . . . . . . . . . . . .
                   143426362         . 1 1 . . . . . . . . . . . . .
                  1292517487         . 1 1 . . . . . . . . . . . . .
                  1564891499         . 1 1 . . . . . . . . . . . . .
                    70642489  11221542 1 1 . . . . . . . . . . . . .
                  1496920047         . 2 1 . . . . . . . . . . . . .
                   681433447         . 2 1 0 0 0 0 0 0 0 0 0 0 0 1 0
                   136749375         . 1 1 . . . . . . . . . . . . .
                   694091645  95574379 1 1 . . . . . . . . . . . . .
                  1021262771         . 2 1 . . . . . . . . . . . . .
                   137010487         . 1 1 . . . . . . . . . . . . .
                   681084615         . 1 1 . . . . . . . . . . . . .
                   952172731         . 1 1 . . . . . . . . . . . . .
                   408964247         . 2 1 . . . . . . . . . . . . .
                   750696207         . 1 1 . . . . . . . . . . . . .
                  1501555804         . 1 1 . . . . . . . . . . . . .
                   204841303         . 1 1 . . . . . . . . . . . . .
                  1428233247         . 2 1 . . . . . . . . . . . . .
                   476830971         . 2 1 . . . . . . . . . . . . .
                   218361605  95304339 1 1 . . . . . . . . . . . . .
                   490342569 116780584 1 1 . . . . . . . . . . . . .
                   341064889  18385869 2 1 . . . . . . . . . . . . .
                   206628889  28951875 1 1 . . . . . . . . . . . . .
                   681140371         . 2 1 . . . . . . . . . . . . .
                   816159811         . 2 1 . . . . . . . . . . . . .
                  1156160487         . 1 1 . . . . . . . . . . . . .
                  1225981535         . 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0
                    68667767         . 1 1 . . . . . . . . . . . . .
                   341224007         . 2 1 . . . . . . . . . . . . .
                   218377933 105285838 1 1 . . . . . . . . . . . . .
                   752250084         . 2 1 . . . . . . . . . . . . .
                   748291727         . 2 1 . . . . . . . . . . . . .
                   163984045 119099918 1 1 . . . . . . . . . . . . .
                    69326687         . 1 1 . . . . . . . . . . . . .
                   163971129 119089459 2 1 . . . . . . . . . . . . .
                   218398333 156018985 1 1 . . . . . . . . . . . . .
                   340423647         . 1 1 . . . . . . . . . . . . .
                   496855613  98485695 1 1 . . . . . . . . . . . . .
                   816199931         . 2 1 . . . . . . . . . . . . .
                   545355297 171552954 2 1 . . . . . . . . . . . . .
                   408357695         . 1 1 . . . . . . . . . . . . .
                   232159485 119261235 2 1 . . . . . . . . . . . . .
                  1088232567         . 1 1 . . . . . . . . . . . . .
                   367605973 118569481 1 1 . . . . . . . . . . . . .
                   218411249  95843639 1 1 . . . . . . . . . . . . .
                   136760927         . 1 1 . . . . . . . . . . . . .
                  1564147567         . 2 1 . . . . . . . . . . . . .
                   748571964         . 2 1 . . . . . . . . . . . . .
                  1157022735         . 1 1 . . . . . . . . . . . . .
                  1021606855         . 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0
                  1088362447         . 1 1 . . . . . . . . . . . . .
                   750516005  14524368 1 1 . . . . . . . . . . . . .
                   816707211         . 1 1 . . . . . . . . . . . . .
                  1565033615         . 2 1 . . . . . . . . . . . . .
                  1360542655         . 1 1 . . . . . . . . . . . . .
                  1566525531         . 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0
                  1088314167         . 2 1 . . . . . . . . . . . . .
                      956765  17401356 1 1 . . . . . . . . . . . . .
                   612021085  10197087 2 1 . . . . . . . . . . . . .
                   272151651         . 2 1 . . . . . . . . . . . . .
                   274239251         . 2 1 0 0 0 0 0 0 0 0 0 0 0 1 0
                  1156575971         . 1 1 . . . . . . . . . . . . .
                  1088715367         . 2 1 . . . . . . . . . . . . .
                  1089160087         . 1 1 . . . . . . . . . . . . .
                   275781485  18503446 2 1 . . . . . . . . . . . . .
                   204574611         . 1 1 . . . . . . . . . . . . .
                   837186089 157347206 2 1 . . . . . . . . . . . . .
                   408348851         . 1 1 . . . . . . . . . . . . .
                   953094127         . 1 1 . . . . . . . . . . . . .
                    69082571         . 2 1 . . . . . . . . . . . . .
                  1088259771         . 1 1 . . . . . . . . . . . . .
                   612992815         . 2 1 . . . . . . . . . . . . .
                   218479257  96353228 1 1 . . . . . . . . . . . . .
                   953206331         . 2 1 . . . . . . . . . . . . .
                  1292750735         . 2 1 . . . . . . . . . . . . .
                  end
                  label values pid pid
                  label values sex c_sex
                  label def c_sex 1 "male", modify
                  label def c_sex 2 "female", modify
                  label values unsafe1 c_unsafe1
                  label def c_unsafe1 0 "not mentioned", modify
                  label values unsafe2 c_unsafe2
                  label def c_unsafe2 0 "not mentioned", modify
                  label values unsafe3 c_unsafe3
                  label def c_unsafe3 0 "not mentioned", modify
                  label values unsafe4 c_unsafe4
                  label def c_unsafe4 0 "not mentioned", modify
                  label values unsafe5 c_unsafe5
                  label def c_unsafe5 0 "not mentioned", modify
                  label values unsafe6 c_unsafe6
                  label def c_unsafe6 0 "not mentioned", modify
                  label values unsafe7 c_unsafe7
                  label def c_unsafe7 0 "not mentioned", modify
                  label values unsafe8 c_unsafe8
                  label def c_unsafe8 0 "not mentioned", modify
                  label values unsafe9 c_unsafe9
                  label def c_unsafe9 0 "not mentioned", modify
                  label values unsafe10 c_unsafe10
                  label def c_unsafe10 0 "not mentioned", modify
                  label values unsafe11 c_unsafe11
                  label def c_unsafe11 0 "not mentioned", modify
                  label values unsafe96 c_unsafe96
                  label def c_unsafe96 1 "Mentioned", modify
                  label values unsafe97 c_unsafe97
                  label def c_unsafe97 0 "not mentioned", modify

                  Comment


                  • #10
                    Thanks for the new data example. This may or may not help. It's destructive, so save the dataset first if not already done.


                    Code:
                    . reshape long unsafe , i(pidp) j(which)
                    (j = 1 2 3 4 5 6 7 8 9 10 11 96 97)
                    
                    Data                               Wide   ->   Long
                    -----------------------------------------------------------------------------
                    Number of observations              100   ->   1,300       
                    Number of variables                  17   ->   6           
                    j variable (13 values)                    ->   which
                    xij variables:
                               unsafe1 unsafe2 ... unsafe97   ->   unsafe
                    -----------------------------------------------------------------------------
                    
                    . 
                    . drop pid* 
                    
                    . drop if missing(unsafe)
                    (1,196 observations deleted)
                    
                    . 
                    . groups wave sex which unsafe , percent(wave sex which) sepby(wave sex which)
                    
                      +---------------------------------------------------------+
                      | wave      sex   which          unsafe   Freq.   Percent |
                      |---------------------------------------------------------|
                      |    1     male       1   not mentioned       5    100.00 |
                      |---------------------------------------------------------|
                      |    1     male       2   not mentioned       5    100.00 |
                      |---------------------------------------------------------|
                      |    1     male       3   not mentioned       5    100.00 |
                      |---------------------------------------------------------|
                      |    1     male       4   not mentioned       5    100.00 |
                      |---------------------------------------------------------|
                      |    1     male       5   not mentioned       5    100.00 |
                      |---------------------------------------------------------|
                      |    1     male       6   not mentioned       5    100.00 |
                      |---------------------------------------------------------|
                      |    1     male       7   not mentioned       5    100.00 |
                      |---------------------------------------------------------|
                      |    1     male       8   not mentioned       5    100.00 |
                      |---------------------------------------------------------|
                      |    1     male       9   not mentioned       5    100.00 |
                      |---------------------------------------------------------|
                      |    1     male      10   not mentioned       5    100.00 |
                      |---------------------------------------------------------|
                      |    1     male      11   not mentioned       5    100.00 |
                      |---------------------------------------------------------|
                      |    1     male      96               1       5    100.00 |
                      |---------------------------------------------------------|
                      |    1     male      97   not mentioned       5    100.00 |
                      |---------------------------------------------------------|
                      |    1   female       1   not mentioned       3    100.00 |
                      |---------------------------------------------------------|
                      |    1   female       2   not mentioned       3    100.00 |
                      |---------------------------------------------------------|
                      |    1   female       3   not mentioned       3    100.00 |
                      |---------------------------------------------------------|
                      |    1   female       4   not mentioned       3    100.00 |
                      |---------------------------------------------------------|
                      |    1   female       5   not mentioned       3    100.00 |
                      |---------------------------------------------------------|
                      |    1   female       6   not mentioned       3    100.00 |
                      |---------------------------------------------------------|
                      |    1   female       7   not mentioned       3    100.00 |
                      |---------------------------------------------------------|
                      |    1   female       8   not mentioned       3    100.00 |
                      |---------------------------------------------------------|
                      |    1   female       9   not mentioned       3    100.00 |
                      |---------------------------------------------------------|
                      |    1   female      10   not mentioned       3    100.00 |
                      |---------------------------------------------------------|
                      |    1   female      11   not mentioned       3    100.00 |
                      |---------------------------------------------------------|
                      |    1   female      96               1       3    100.00 |
                      |---------------------------------------------------------|
                      |    1   female      97   not mentioned       3    100.00 |
                      +---------------------------------------------------------+

                    Comment


                    • #11
                      Thank you very much!

                      Comment

                      Working...
                      X