Content
. /**
> * A do file to run the standard stats for a whole data set.
> *
> * Note that you must delete the files in the derived directory
> * for changes to be reflected in the output.
> *
> * @version 0.1
> */
.
. // profiler on
.
. import delimited "/home/schaffne/Dropbox/Public/efn508/additionaldatafiles/__MACOSX/._taylor.csv"
(2 vars, 2 obs)
.
. describe, short
Contains data
obs: 2
vars: 2
size: 416
Sorted by:
Note: dataset has changed since last saved
.
. local N = r(N)
. local variables = r(k)
.
. di "@N `N'"
@N 2
. di "@variables `variables'"
@variables 2
.
. datasignature
2:2(90324):173873926:3951975490
. local datasig = "`r(datasignature)'"
.
. di "@datasignature `datasig'"
@datasignature 2:2(90324):173873926:3951975490
.
. cap noi xtset
panel variable not set; use xtset varname ...
. if ( !_rc ) {
. di "@timevar `r(timevar)'"
. di "@panelvar `r(panelvar)'"
. }
.
. notes _dta
.
. qui {
.
. foreach var of varlist * {
2.
. di "=====`var'====="
3. qui {
4. local category_cutoff = 100
5.
. // this takes very long on large datasets (and does mostly the same as other things below)
. // codebook `var'
.
. local isstr = ""
6. local unique = ""
7. local total = ""
8. local class = ""
9.
. local type : type `var'
10. local label : variable label `var'
11.
. local class = "other"
12.
. // test for string
. capture confirm string variable `var'
13. if ( !_rc ) {
14. // we now it is a string
. local isstr = "YES"
15. capture tab `var', matcell( freq )
16. if ( !_rc ) {
17.
. // not too many obs
. local total = `r(N)'
18. local unique = r(r)
19.
. if ( `unique' < `category_cutoff' ) {
20. forvalues i=1/`unique' {
21. if ( `i' == 1 ) {
22. noi di "@freq " _continue
23. }
24. noi di freq[`i',1] _continue
25. if ( `i' == `unique' ) {
26. noi di ""
27. }
28. else {
29. noi di ", " _continue
30. }
31. }
32.
. levelsof `var', local(levels)
33. local i = 1
34. foreach l of local levels {
35. if ( `i' == 1 ) {
36. noi di "@values " _continue
37. }
38. noi di `""`l'""' _continue
39. if ( `i' == `unique' ) {
40. noi di ""
41. }
42. else {
43. noi di ", " _continue
44. }
45. local i = `i' + 1
46. }
47. }
48.
. if ( `total' == 0 ) {
49. local class = "empty"
50. }
51. else if ( `unique' == 1 ) {
52. local class = "constant"
53. }
54. else if ( `unique' == 2 ) {
55. local class = "dummy"
56. }
57. else if ( `unique' < `category_cutoff' & `unique' < `total' ) {
58. local class = "category"
59. }
60. else if (`unique' == `total') {
61. local class = "identifier"
62. }
63. else {
64. local class = "string"
65. }
66. }
67. else {
68. // lots of observations, not sure what to do yet
. // should get random samples here
. noi di "@example0 " `var'[1]
69. }
70. }
71. else {
72. // else assume it is numeric
.
. noi inspect `var'
73.
. local total = r(N)
74. local unique = r(N_unique)
75.
. if ( `unique' < `category_cutoff' ) {
76. local cat = "YES"
77. }
78.
. if ( "`unique'" != "." ) {
79. if ( `total' == 0 ) {
80. local class = "empty"
81. }
82. else if ( `unique' == 1 ) {
83. local class = "constant"
84. }
85. else if ( `unique' == 2 ) {
86. local class = "dummy"
87. }
88. else if ( `unique' < `category_cutoff' & `unique' < `total' ) {
89. capture confirm string variable `var'
90. if ( !_rc ) {
91. local class = "other"
92. }
93. else {
94. local class = "category"
95. }
96. }
97. else if (`r(N_unique)' == `r(N)') {
98. local class = "identifier"
99. }
100. }
101.
. // TODO this takes too long? sum `var', detail
. noi sum `var'
102. local min = r(min)
103. local max = r(max)
104. local nobs = r(N)
105.
. // TODO maybe the precision should be handled later (vm?)
. if ( ( "`type'" != "double" & "`type'" != "float" ) & "`class'" == "constant" ) {
106. noi di "@mean " %9.0f r(mean)
107. }
108. else {
109. noi di "@mean " %9.3f r(mean)
110. }
111. noi di "@sd " %9.3f `r(sd)'
112. // noi di "@skewness " %9.3f `r(skewness)'
. // noi di "@kurtosis " %9.3f `r(kurtosis)'
.
. if ( "`type'" == "double" | "`type'" == "float" ) {
113. noi di "@min " %9.3f `r(min)'
114. noi di "@max " %9.3f `r(max)'
115. // noi di "@p50 " %9.3f `r(p50)'
. }
116. else {
117. noi di "@min " %9.0f `r(min)'
118. noi di "@max " %9.0f `r(max)'
119. // noi di "@p50 " %9.0f `r(p50)'
. }
120. }
121.
.
. if ( ( "`class'" == "constant" ) & ( "`isstr'"!= "YES" ) ) {
122. noi di "@values " `var'[1]
123. }
124. else if ( "`class'" == "category" | "`class'" == "dummy" ) {
125. cap noi {
126. if ( "`isstr'" != "YES" ) {
127. cap tab `var', matcell( freq ) matrow( name )
128. if ( _rc != 0 | ("`r(r)'" != "`unique'") ) {
129. local class = "other"
130. local unique = r(r)
131. }
132. else {
133. forvalues i=1/`unique' {
134. if ( `i' == 1 ) {
135. noi di "@values " _continue
136. }
137. noi di name[`i',1] _continue
138. if ( `i' == `unique' ) {
139. noi di ""
140. }
141. else {
142. noi di ", " _continue
143. }
144. }
145. forvalues i=1/`unique' {
146. if ( `i' == 1 ) {
147. noi di "@names " _continue
148. }
149. local val = name[`i',1]
150. local lab :label (`var') `val'
151. noi di `""`lab'""' _continue
152. if ( `i' == `unique' ) {
153. noi di ""
154. }
155. else {
156. noi di ", " _continue
157. }
158. }
159. forvalues i=1/`unique' {
160. if ( `i' == 1 ) {
161. noi di "@freq " _continue
162. }
163. noi di freq[`i',1] _continue
164. if ( `i' == `unique' ) {
165. noi di ""
166. }
167. else {
168. noi di ", " _continue
169. }
170. }
171. }
172. }
173. }
174. }
175. else {
176. noi di "@example0 " `var'[1]
177. }
178.
. // histogram
. if ( "`isstr'" != "YES" & ("`class'" == "other" | "`class'" == "identifier") ) {
179. cap noi {
180. tempvar h w
181. twoway__histogram_gen `var', gen( `h' `w' )
182. forvalues i=1/`=r(n_x)' {
183. if ( `i' == 1 ) {
184. noi di "@histh " _continue
185. }
186. noi di `h'[`i'] _continue
187. if ( `i' == `=r(n_x)' ) {
188. noi di ""
189. }
190. else {
191. noi di ", " _continue
192. }
193. }
194. forvalues i=1/`=r(n_x)' {
195. if ( `i' == 1 ) {
196. noi di "@histw " _continue
197. }
198. noi di `w'[`i'] _continue
199. if ( `i' == `=r(n_x)' ) {
200. noi di ""
201. }
202. else {
203. noi di ", " _continue
204. }
205. }
206. }
207. }
208.
. noi di "@type `type'"
209. noi di "@label `label'"
210. noi di "@class `class'"
211. noi di "@N_unique `unique'"
212. noi di "@N `total'"
213.
. noi notes `var'
214. }
215.
.
. }
=====v1=====
@freq 1
too few quotes
r(132):r(132);
end of do-file
r(132):r(132);