You are on page 1of 2

Lab 6 New.

do - Printed on 08/11/2023 5:42:59 pm


1 /*
2 Eeman Shahzad Qureshi
3 SDA Lab 5- Standardization and Data distribution
4 28th Feb 2023
5 */
6
7 *Importing excel data:
8
9 import excel "C:\Users\HP\Documents\SDA Spring Semester 2023\Lab 5\student_scores.xls", sheet(
"Sheet1") firstrow clear
10
11
12 *Q2:Recoding a Continuous Variable into a categorical variable:
13
14 generate GRE_group = 1 if inrange(GRE,281,299)
15 replace GRE_group = 2 if inrange(GRE,300,320)
16 replace GRE_group= 3 if inrange(GRE,321,338)
17
18 label define GRE 1 "Below Average" 2 "Above Average" 3 "Excellent", replace
19 label value GRE GRE_group
20
21 tab GRE_group
22 tab GRE_group, nolabel
23
24 *OR:
25
26 recode GRE (min/299=1 "Below Average") (300/320=2 "Above Average") (321/max=3 "Excellent"),
gen(GRE_group)
27
28 //Note the recode command changes the actual variable so we add the generate option at the end
in order to create a new variable with the conditions.
29
30 tab GRE_group
31 tab GRE_group, nolabel
32
33 *Summary Statistics:
34
35 sum ACT SAT GRE
36
37 *Standardization of scores:
38
39 di (1300-1187.5253)/233.056 // SAT
40 di (954-776.359)/118.5253 // ACT
41
42 *Automating calculations through locals:
43
44 sum ACT
45
46 return list
47
48 di(954-`r(mean)')/`r(sd)'
49
50 sum SAT
51
52 return list
53
54 di(1300-`r(mean)')/`r(sd)'
55
56
57 *Generating Standardized Variables using Locals:
58
59 sum ACT
60

Page 1
Lab 6 New.do - Printed on 08/11/2023 5:43:00 pm
61 gen ACT_standardized= (ACT-`r(mean)')/`r(sd)'
62
63 br name ACT ACT_standardized
64
65 *Checking if ACT_standardized is normally distributed
66
67 sum ACT
68
69 count if ACT_standardized > `r(mean)'
70
71 *How to check if ACT_standardized is normally distributed through graph command:
72
73 histogram ACT_standardized, freq normal
74
75 *Check for Skewness:
76
77 sum ACT, d
78
79 *Graph form
80
81 histogram ACT, freq normal
82
83
84 *Check for Kurtosis:
85
86 sum ACT, d
87
88 di `r(kurtosis)'-3
89 //Note to run this command you must first run the sum detail command
90
91
92 *Q7:
93
94 di 1.91-3
95 //returns a negative value so distribution is platykurtic.
96
97
98
99
100
101
102
103
104
105

Page 2

You might also like