I am trying to create a histogram with a string variable. In the example dataset below, I have a string variable called SchoolName which identifies where someone currently attends college. I also have a numeric variable called Studentid which identifies a unique student. I want to create a histogram with the string variable SchoolName.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte Studentid str25 SchoolName 1 "Purdue University" 2 "Purdue University" 3 "Purdue University" 4 "Purdue University" 5 "Purdue University" 6 "Indiana University" 7 "Indiana University" 8 "Indiana University" 9 "Indiana University" 10 "University of Michigan" 11 "University of Michigan" 12 "University of Michigan" 13 "University of Michigan" 14 "University of Michigan" 15 "University of Michigan" 16 "University of Michigan" 17 "University of Michigan" 18 "Michigan State University" 19 "Michigan State University" 20 "University of Maryland" 21 "University of Maryland" 22 "University of Maryland" 23 "University of Maryland" 24 "University of Maryland" 25 "University of Maryland" 26 "University of Maryland" 27 "University of Maryland" 28 "University of Maryland" 29 "University of Maryland" 30 "University of Maryland" 31 "University of Maryland" 32 "University of Maryland" 33 "University of Illinois" 34 "University of Illinois" 35 "University of Illinois" 36 "University of Illinois" 37 "University of Illinois" 38 "University of Illinois" 39 "University of Illinois" 40 "University of Iowa" 41 "University of Minnesota" 42 "University of Minnesota" 43 "University of Minnesota" 44 "University of Minnesota" 45 "University of Minnesota" 46 "University of Minnesota" 47 "University of Minnesota" 48 "University of Minnesota" 49 "University of Minnesota" 50 "University of Minnesota" 51 "University of Minnesota" 52 "University of Minnesota" 53 "University of Minnesota" 54 "University of Minnesota" 55 "University of Minnesota" 56 "University of Minnesota" 57 "University of Minnesota" 58 "University of Minnesota" 59 "University of Nebraska" 60 "University of Nebraska" 61 "University of Nebraska" 62 "University of Nebraska" 63 "Northwestern University" 64 "Northwestern University" 65 "Northwestern University" 66 "Northwestern University" 67 "Northwestern University" 68 "Northwestern University" 69 "Northwestern University" 70 "Ohio State University" 71 "Ohio State University" 72 "Ohio State University" 73 "Ohio State University" 74 "Ohio State University" 75 "Ohio State University" 76 "Ohio State University" 77 "Ohio State University" 78 "Ohio State University" 79 "Ohio State University" 80 "Ohio State University" 81 "University of Wisconsin" 82 "University of Wisconsin" 83 "University of Wisconsin" 84 "University of Wisconsin" 85 "University of Wisconsin" 86 "University of Wisconsin" 87 "University of Wisconsin" 88 "University of Wisconsin" 89 "University of Wisconsin" 90 "University of Wisconsin" end
I would like to create a histogram identifying only the top three schools that are most frequently attended. I would like the histogram to include a label with the frequency count and a label with the name of the school. I am currently using Stata 16. Thank you so much.
0 Response to Creating a histogram with categorical data
Post a Comment