Announcement

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

  • #16
    *they are associated

    Comment


    • #17
      That's not how recode works to do what you want. You changed the labels (only). So, you will get the same graph but incorrectly labelled.

      Comment


      • #18
        Dear Nick Cox thanks a lot.
        I use your code but there's a problem..I got the desired order but with mismatched percentages. They are associated with the old order. Where is the mistake ??



        Code:
        recode preference (1 = 1 "Other") (2 = 2 "Program for matching an autistic person with a non-autistic peer") (3 = 3 "Program for matching autistic peers with each other") (4 = 4 "Behavior training in groups") (5 = 5 "Behavior training, for an individual") (6 = 6 "Family relations support and counseling") (7 = 7 "Free time activities") (8 = 8 "Support groups, in person") (9 = 9 "Support group, on-line") (10 = 10 "Life skills training") (11 = 11 "Adult satisfied") , pre(new) label(newrep)

        Comment


        • #19
          Can you help me ?
          I am going through hard times

          Comment


          • #20
            This may help. I am not fluent in recode for uninteresting reasons. I just had to read the help file like anybody has to. The spineplot is not helpful without the frequency weights.

            Code:
            * Example generated by -dataex-. To install: ssc install dataex
            clear
            input long(group preference) int _freq
            1  1 115
            2  1  25
            3  1  38
            1  2  51
            2  2  19
            3  2  29
            4  2  23
            1  3   9
            2  3  16
            3  3   5
            4  3  12
            1  4  31
            2  4  12
            3  4   9
            4  4  14
            1  5  34
            2  5  20
            3  5  30
            4  5  23
            1  7  45
            2  7  37
            3  7  47
            4  7  60
            1  8  34
            2  8  11
            3  8   9
            4  8  12
            1  9  36
            2  9  37
            3  9  26
            4  9  13
            1 10  49
            2 10  19
            3 10  12
            4 10  10
            1 11  31
            2 11   8
            3 11   1
            4 11  14
            1 12   9
            2 12   3
            4 12   5
            end
            label values group group
            label def group 1 "Autistic adult", modify
            label def group 2 "High", modify
            label def group 3 "Low", modify
            label def group 4 "Professional", modify
            label values preference preference
            label def preference 1 "Adult satisfied", modify
            label def preference 2 "Behavior training, for an individual", modify
            label def preference 3 "Behavior training, in groups", modify
            label def preference 4 "Family relation support and counseling", modify
            label def preference 5 "Free time activities", modify
            label def preference 7 "Life skills training", modify
            label def preference 8 "Other", modify
            label def preference 9 "Program for matching an autistic person with a-non autistic peer", modify
            label def preference 10 "Program for matching autistic peers with each other", modify
            label def preference 11 "Support groups in person", modify
            label def preference 12 "Support groups, on line", modify
            **# Bookmark #1
            
            recode preference (1=1 "Adult satisfied") (7=2 "Life skills training") (12=3 "Support group, on-line") (11=4 "Support groups, in person") (5=5 "Free time activities") (4=6 "Family relations support and counseling") (2=7 "Behavior training, for an individual") (3=8 "Behavior training in groups") (10=9 "Program for matching autistic peers with each other") (9=10 "Program for matching an autistic person with a non-autistic peer") (8=11 "Other") ,  gen(PREFERENCE) 
            
            label var PREFERENCE preference
            
            spineplot  PREFERENCE group [fw=_freq], legend(size(tiny)) xtitle(" ") xlabel("") ///
            percent ylab(0(10)100, labsize(tiny) axis(2)) ///
            xlab(, labsize(vsmall) axis(2)) name(third, replace) ///
            bar1(bcolor(cyan))  bar2(bcolor(mint))  /// 
            bar3(bcolor(lime)) bar4(bcolor(midgreen))  bar5(bcolor(dkgreen))  ///  
            bar6(bcolor(red)) bar7(bcolor(orange)) bar8(bcolor(yellow)) /// 
            bar9(bcolor(pink))  bar10(bcolor(cranberry)) bar11(bcolor(purple))

            Comment


            • #21
              Thank you..But at the end i resolved the problem by myself...

              Comment


              • #22
                I appreciate a lot your help Nick Cox

                Comment


                • #23
                  Sounds good. If your solution was different, you should share it.

                  Comment


                  • #24
                    ok
                    Code:
                    label define order1  1 "Adult satisfied"  2 "Life skills training"  3 "Support groups, on-line" ///
                    4 "Support groups, in person"  5 "Free time activities"  6 "Family relations support and counseling" ///
                    7 "Behavior training, for an individual" 8 "Behavior training, in groups" ///
                    9 "Program for matching autistic peers with each other" ///
                    10 "Program for matching an autistic person with a non-autistic peer"  11 "Other"
                    
                    
                    
                    encode Preference, gen(preference_ord) label(order1)
                    
                    
                     encode Group, gen(group)

                    Comment


                    • #25
                      and the code for the plot is the same
                      i don't use "recode"

                      Thanks a lot Nick Cox

                      Comment


                      • #26
                        So if I understand you correctly. you're using a string variable Preference not so far mentioned in the thread. That is fine by me, but needs a better explanation to be clear to anyone not studying posts here really closely.

                        To recap, my solution using recode hinged on your showing us a numeric preference variable that needed to be re-ordered. Starting from a string variable and giving a different encode is an equivalent solution.

                        Comment

                        Working...
                        X