Hello,
I have data on perceived and actual social norms and wish to have a variable that, for each respondent, records the deviation from the average across all respondents.
I would like to create a bar graph showing the distribution of people's beliefs about the share of UK students who say they try to fight global warming in relation to the actual share i.e. a distribution of the 'wedge' between perceived social norms and the actual share.
Variables:
NBpriorBehSelf: "Do you try to fight global warming?" (Yes/No)
NBpriorBehOthr: "Out of 100 people, how many students do you think try to fight global warming?" (1-100)
I have tried various things and believe I am closest with the following commands but I'm left with the questions
(a) how to create a variable for the 'actual %' (NBpriorBehSelf="yes" or 1)
(b) how to graph it as I haven't quite yet managed to get the graph similar to the given one?
egen actual=pc(NBpriorBehSelf) or
egen actual=mean(NBpriorBehSelf) if Groupid==1
generate deviation = NBpriorBehOthr - actual
tw hist deviation, discrete lcolor(gray) fcolor(gray%50) percent xtitle("Wedge (guess%= % - actual %)")
Included below is the (i) intended type of graph (iii) dataex and code

I really appreciate any advice while I learn and build my understanding of Stata's capabilities and if any further clarification or information would be useful, please let know.
Best wishes,
Janina
I have data on perceived and actual social norms and wish to have a variable that, for each respondent, records the deviation from the average across all respondents.
I would like to create a bar graph showing the distribution of people's beliefs about the share of UK students who say they try to fight global warming in relation to the actual share i.e. a distribution of the 'wedge' between perceived social norms and the actual share.
Variables:
NBpriorBehSelf: "Do you try to fight global warming?" (Yes/No)
NBpriorBehOthr: "Out of 100 people, how many students do you think try to fight global warming?" (1-100)
I have tried various things and believe I am closest with the following commands but I'm left with the questions
(a) how to create a variable for the 'actual %' (NBpriorBehSelf="yes" or 1)
(b) how to graph it as I haven't quite yet managed to get the graph similar to the given one?
egen actual=pc(NBpriorBehSelf) or
egen actual=mean(NBpriorBehSelf) if Groupid==1
generate deviation = NBpriorBehOthr - actual
tw hist deviation, discrete lcolor(gray) fcolor(gray%50) percent xtitle("Wedge (guess%= % - actual %)")
Included below is the (i) intended type of graph (iii) dataex and code
Code:
* Example generated by -dataex-. For more info, type help dataex clear * dataex NBpriorBehSelf NBpriorBehOthr input byte(NBpriorBehSelf NBpriorBehOthr) 1 80 1 83 1 80 1 40 1 60 1 89 1 65 1 70 1 78 1 40 1 50 1 90 1 46 1 90 2 61 1 70 1 90 2 40 1 97 1 60 1 88 1 71 1 80 1 47 1 40 1 92 2 87 1 90 1 90 1 83 1 98 1 100 1 80 1 60 1 60 1 75 1 80 2 91 1 80 1 90 1 85 1 80 1 71 1 70 1 61 1 97 1 57 2 61 1 95 1 90 1 80 1 85 1 81 1 80 1 90 2 1 1 95 1 75 2 66 1 87 1 80 1 60 1 70 1 91 1 44 1 69 1 90 1 76 2 20 1 70 2 10 1 45 1 70 1 70 1 47 1 85 1 81 1 61 1 59 1 60 2 60 1 100 1 80 1 60 1 73 1 95 1 80 1 76 1 83 2 16 2 78 1 75 1 68 1 79 1 94 1 90 2 17 2 20 1 60 end label values NBpriorBehSelf NBpriorBehSelf_lbl label def NBpriorBehSelf_lbl 1 "yes", modify label def NBpriorBehSelf_lbl 2 "no", modify
Best wishes,
Janina
Comment