Announcement

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

  • Sort multiple response answers

    I have a survey dataset where the researcher asked a multiple response question regarding skin conditions. The answer looks like this (see below). I want to separate out the skin conditions by type and then calculate the frequency count for each skin condition. Your assistance will be appreciated.

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str86 question1
    "Dry lips"                               
    "Acne"                                   
    "Skin Cancer"                            
    "Sun spots/Moles"                        
    "Skin Cancer, Allergic Dermatitis"       
    ""                                       
    ""                                       
    ""                                       
    ""                                       
    "Skin Cancer"                            
    ""                                       
    "Sun spots/Moles"                        
    ""                                       
    "Skin Cancer, Sun spots/Moles"           
    "Psoriasis"                              
    ""                                       
    "Lupus/other auto-immune skin conditions"
    ""                                       
    "Sun spots/Moles, Skin tags"             
    "Acne"                                   
    "Acne"                                   
    ""                                       
    "Skin Cancer"                            
    ""                                       
    "Skin Cancer"                            
    ""                                       
    "Skin Cancer"                            
    "Rosacea, Skin Cancer"                   
    ""                                       
    "Skin Cancer"                            
    "Eczema"                                 
    "Psoriasis"                              
    "Skin Cancer"                            
    "Skin Cancer, Psoriasis"                 
    "Sun spots/Moles"                        
    ""                                       
    "Skin Cancer"                            
    "Sun spots/Moles, Seborrheic dermatitis"
    "Skin Cancer"                            
    "Skin Cancer"                            
    ""                                       
    "Lupus/other auto-immune skin conditions"
    "Sun spots/Moles"                        
    "Other"                                  
    "Fungus"                                 
    "Skin Cancer"                            
    "Sun spots/Moles"                        
    "Skin Cancer"                            
    "Eczema"                                 
    "Sour ??? (illegible)"                   
    "Allergic Dermatitis"                    
    "Other"                                  
    "Viral Warts, Sun spots/Moles"           
    "Sun spots/Moles"                        
    "None"                                   
    "Sun spots/Moles, Porokeratosis"         
    ""                                       
    "Other: Pre-cancer"                      
    "Acne, Other"                            
    "Viral Warts"                            
    ""                                       
    "Annual skin, nails peeling"             
    "Other: ??? (illegible)"                 
    "Non-healing wound"                      
    ""                                       
    "Skin Cancer"                            
    "Skin Cancer, Sun spots/Moles"           
    "Hair loss"                              
    "Psoriasis"                              
    ""                                       
    "Eczema, Psoriasis"                      
    ""                                       
    ""                                       
    "Cyst"                                   
    "Skin Cancer, Sun spots/Moles"           
    ""                                       
    ""                                       
    "Lupus/other auto-immune skin conditions"
    "Skin Cancer"                            
    "Sun spots/Moles, Other"                 
    "Skin Cancer"                            
    "Skin Cancer"                            
    "Sun spots/Moles"                        
    "Skin Cancer"                            
    "Hair loss"                              
    "Skin Cancer, Check-up"                  
    "Acne"                                   
    "Skin Cancer"                            
    "Sun spots/Moles"                        
    "Eczema"                                 
    "Skin Cancer, Sun spots/Moles"           
    "Skin Cancer"                            
    "Vitiligo or other pigment conditions"   
    "Sun spots/Moles"                        
    "Actinic keratoses"                      
    "Scalp pain/Itching"                     
    "Hair loss, Shingles"                    
    "Rosacea"                                
    "Skin Cancer (CTCL)"                     
    "Yearly follow-up (carcinoma)"           
    end
    ------------------ copy up to and including the previous line ------------------



  • #2
    Thanks for the data example. I used tabsplit from tab_chi on SSC to do this:

    Code:
    . tabsplit question1, parse(,) sort 
    
                                  question1 |      Freq.     Percent        Cum.
    ----------------------------------------+-----------------------------------
                                Skin Cancer |         27       28.42       28.42
                            Sun spots/Moles |         18       18.95       47.37
                                       Acne |          5        5.26       52.63
                                  Psoriasis |          5        5.26       57.89
                                     Eczema |          4        4.21       62.11
                                      Other |          4        4.21       66.32
                                  Hair loss |          3        3.16       69.47
    Lupus/other auto-immune skin conditions |          3        3.16       72.63
                        Allergic Dermatitis |          2        2.11       74.74
                                    Rosacea |          2        2.11       76.84
                                Viral Warts |          2        2.11       78.95
                          Actinic keratoses |          1        1.05       80.00
                                Annual skin |          1        1.05       81.05
                                   Check-up |          1        1.05       82.11
                                       Cyst |          1        1.05       83.16
                                   Dry lips |          1        1.05       84.21
                                     Fungus |          1        1.05       85.26
                          Non-healing wound |          1        1.05       86.32
                                       None |          1        1.05       87.37
                     Other: ??? (illegible) |          1        1.05       88.42
                          Other: Pre-cancer |          1        1.05       89.47
                              Porokeratosis |          1        1.05       90.53
                         Scalp pain/Itching |          1        1.05       91.58
                      Seborrheic dermatitis |          1        1.05       92.63
                                   Shingles |          1        1.05       93.68
                         Skin Cancer (CTCL) |          1        1.05       94.74
                                  Skin tags |          1        1.05       95.79
                       Sour ??? (illegible) |          1        1.05       96.84
       Vitiligo or other pigment conditions |          1        1.05       97.89
               Yearly follow-up (carcinoma) |          1        1.05       98.95
                              nails peeling |          1        1.05      100.00
    ----------------------------------------+-----------------------------------
                                      Total |         95      100.00
    The command name and package name are good terms for searches in the forum archives. Note that tabsplit like tabulate (which it calls) is sensitive to differences of upper case and lower case. That doesn't seem to bite here.

    Comment


    • #3
      Al:
      you may want to try:
      Code:
      . encode question1, g(question1_labelled)
      
      . bysort question1_labelled: egen wanted=count( question1_labelled )
      ETA: a bit late to the party, bringing a different bottle od wine!
      Kind regards,
      Carlo
      (StataNow 18.5)

      Comment


      • #4
        Thanks! I tried the two codes (# 2 & 3), and both work well.

        Comment

        Working...
        X