Exam 1 690C 2020 SOLUTIONS Stata
Exam 1 690C 2020 SOLUTIONS Stata
Questions 1-3
learndis.xlsx.
Overview of Learning Disabilities in Children Study
__a) By any means you like, import learndis.xlsx into R Studio or Stata. Tip - While in Excel, take care that
the columns are saved in the appropriate formats (numeric or text).
__a) By any means you like, create a studyid variable that you name studyid and that has
__2. (20 points total)
genderf:
0 male
1 female
placemenf:
0 Part-time
1 Full-time Segregated
Obs<.
+------------------------------
| | Unique
Variable | Obs=. Obs>. Obs<. | values Min Max
-------------+--------------------------------+------------------------------
readcomp | 29 76 | 35 22 107
mathcomp | 11 94 | 43 61 121
-----------------------------------------------------------------------------
__a) Create a grouped variable that you name quart_iq that has values 1, 2, 3, and 4 according to
quartile of value of iq.
quart_iq -- 4 quantiles of iq
-----------------------------------------------------------
| Freq. Percent Valid Cum.
--------------+--------------------------------------------
Valid 1 | 31 29.52 29.52 29.52
2 | 22 20.95 20.95 50.48
3 | 26 24.76 24.76 75.24
4 | 26 24.76 24.76 100.00
Total | 105 100.00 100.00
-----------------------------------------------------------
. generate quart_iq=iq
. recode quart_iq (min/74.0=1) (74.01/80.0=2) (80.1/89.0=3) (89.1/max=4)
(quart_iq: 105 changes made)
. fre quart_iq
quart_iq
-----------------------------------------------------------
| Freq. Percent Valid Cum.
--------------+--------------------------------------------
Valid 1 | 31 29.52 29.52 29.52
2 | 22 20.95 20.95 50.48
3 | 26 24.76 24.76 75.24
4 | 26 24.76 24.76 100.00
Total | 105 100.00 100.00
-----------------------------------------------------------
quart_iq -- 4 quantiles of iq
------------------------------------------------------------------
| Freq. Percent Valid Cum.
---------------------+--------------------------------------------
Valid 1 Q1: 51-74 | 31 29.52 29.52 29.52
2 Q2: 74-80 | 22 20.95 20.95 50.48
3 Q3: 80-89 | 26 24.76 24.76 75.24
4 Q4: 89-105 | 26 24.76 24.76 100.00
Total | 105 100.00 100.00
------------------------------------------------------------------
Questions 4-5
gss1000.xlsx.
Overview of General Social Survey (GSS)
The variable fepol contains responses to the question “Female not suited for politics” and is coded 1=yes and 0=no. This is
potentially confusing since a value of 1 is saying that the respondent believes females are not suited for politics.
__a) Create a more straightforward variable that you name fepol_yes and that is a reverse coding of fepol.
__c) Assign value labels of “Yes” to the value 1 and “No to the value 0.
. Q4C: Assign labels of “yes” to the value 1 and “no” to the value of 0
. label define fepolyesf 1 "Yes, suited" 0 "Not suited"
. label values fepol_yes fepolyesf
. * Check.
. tab2 fepol fepol_yes
Females |
not suited |
for |
politics |
(yes=1 | Females SUITED for
no=0)? | politics
(recoded) | Not suite Yes, suit | Total
-----------+----------------------+----------
0. No | 0 496 | 496
1. Yes | 133 0 | 133
-----------+----------------------+----------
Total | 133 496 | 629
The variable socbar contains responses to the question “Spend evening at bar” and is coded 1=never, 2 =once a year, 3=sev
times a year, 4=once a month, 5=sev times a mnth, 6=sev times a week, 7=almost daily. There are missing values.
___5a) Create a new variable socbar4 that is a grouping of the values of socbar as follows:
missing 1 Unknown
1 2 Never
2 or 3 or 4 3 At most 1x/month
5 or 6 or 7 4 At least several x/month
. numlabel, add
. tab2 socbar socbar4, missing