----------------------------------------------------------------------------------------------- log: C:\Documents and Settings\student\Desktop\Lab1\lab1.log log type: text opened on: 26 Jan 2005, 09:35:48 . infile week1-week9 using "C:\Documents and Settings\student\Desktop\Lab1\pigs.raw" (48 observations read) . browse . save "C:\Documents and Settings\student\Desktop\Lab1\pigs.dta" file C:\Documents and Settings\student\Desktop\Lab1\pigs.dta saved . clear all . browse . use "C:\Documents and Settings\student\Desktop\Lab1\pigs.stata.dta", clear . edit - preserve . clear all . use "C:\Documents and Settings\student\Desktop\Lab1\pigs.dta" . edit - preserve . g id=_n . * the above command generated teh id=observation number . edit - preserve . browse . edit - preserve - label var week1 "week" . edit - preserve . move id week1 . list +----------------------------------------------------------------------------+ | id week1 week2 week3 week4 week5 week6 week7 week8 week9 | |----------------------------------------------------------------------------| 1. | 1 24 32 39 42.5 48 54.5 61 65 72 | 2. | 2 22.5 30.5 40.5 45 51 58.5 64 72 78 | 3. | 3 22.5 28 36.5 41 47.5 55 61 68 76 | 4. | 4 24 31.5 39.5 44.5 51 56 59.5 64 67 | 5. | 5 24.5 31.5 37 42.5 48 54 58 63 65.5 | |----------------------------------------------------------------------------| 6. | 6 23 30 35.5 41 48 51.5 56.5 63.5 69.5 | 7. | 7 22.5 28.5 36 43.5 47 53.5 59.5 67.5 73.5 | 8. | 8 23.5 30.5 38 41 48.5 55 59.5 66.5 73 | 9. | 9 20 27.5 33 39 43.5 49 54.5 59.5 65 | 10. | 10 25.5 32.5 39.5 47 53 58.5 63 69.5 76 | |----------------------------------------------------------------------------| 11. | 11 24.5 31 40.5 46 51.5 57 62.5 69.5 76 | 12. | 12 24 29 39 44 50.5 57 61.5 68 73.5 | 13. | 13 23.5 30.5 36.5 42 47 55 59 65.5 73 | 14. | 14 21.5 30.5 37 42.5 48 52.5 58.5 63 69.5 | 15. | 15 25 32 38.5 44 51 59 66 75.5 86 | |----------------------------------------------------------------------------| 16. | 16 21.5 28.5 34 39.5 45 51 58 64.5 72.5 | 17. | 17 31 38 48 54 60 62 66.5 75.5 84 | 18. | 18 27.5 32.5 36 43 49.5 52.5 56 61 64 | 19. | 19 30 37 45 51 58 63 67.5 74.5 81 | 20. | 20 26 32 40.5 45.5 52.5 55.5 62.5 69.5 74 | |----------------------------------------------------------------------------| 21. | 21 26 32.5 39.5 44 48 54.5 58 66 73 | 22. | 22 28.5 35.5 41.5 47.5 54 59.5 63.5 71 78.5 | 23. | 23 26.5 34.5 42 48.5 55.5 62 68 76.5 85 | 24. | 24 27.5 33.5 41 45 50.5 56 62.5 71 78 | 25. | 25 22.5 27 33.5 38.5 41 49 56 64 68 | |----------------------------------------------------------------------------| 26. | 26 22 26.5 32.5 38.5 43.5 50.5 56.5 63.5 68.5 | 27. | 27 23.5 29 35.5 40 45 50 56.5 63 67.5 | 28. | 28 22.5 29.5 36.5 42 45 55 61 68 72 | 29. | 29 27.5 34.5 42 47.5 53 63 72 79 85.5 | 30. | 30 23.5 28 33 37 38.5 48 52.5 62 64.5 | |----------------------------------------------------------------------------| 31. | 31 24.5 30 38.5 42 47.5 54 62.5 71.5 77 | 32. | 32 24.5 31.5 40.5 46.5 51.5 61.5 68.5 77.5 84.5 | 33. | 33 24.5 32 39 45 51 55.5 61.5 69 75.5 | 34. | 34 24 32.5 40 48 54.5 61.5 68 74.5 81 | 35. | 35 24 31.5 38.5 44 51.5 57.5 64 72.5 79 | |----------------------------------------------------------------------------| 36. | 36 24.5 32.5 39.5 44.5 52.5 56.5 62 67.5 72.5 | 37. | 37 24.5 32 38.5 44 50 56 63.5 69.5 76 | 38. | 38 25.5 33 41.5 47 55.5 60.5 66.5 77 82 | 39. | 39 25.5 32 39 45.5 51 57.5 63.5 72 78.5 | 40. | 40 25 31 36.5 43 50.5 55 62.5 69 75.5 | |----------------------------------------------------------------------------| 41. | 41 26.5 30.5 33 39 43.5 49.5 56.5 61 65 | 42. | 42 24 32 39 44.5 50 56 63 67.5 74 | 43. | 43 24.5 31 37.5 43.5 48 56 62.5 66.5 70.5 | 44. | 44 27 34.5 42 48.5 53 60 67 73 76 | 45. | 45 31 39 47.5 51 57 64 71 77 80.5 | |----------------------------------------------------------------------------| 46. | 46 27 33.5 40 46.5 53 60 66.5 72.5 80 | 47. | 47 29.5 37 46 52.5 60 67.5 76 81.5 88 | 48. | 48 28.5 36 42.5 49 55 63.5 72 78.5 85.5 | +----------------------------------------------------------------------------+ . list 1/5 1 invalid name r(198); . list in 1/5 +----------------------------------------------------------------------------+ | id week1 week2 week3 week4 week5 week6 week7 week8 week9 | |----------------------------------------------------------------------------| 1. | 1 24 32 39 42.5 48 54.5 61 65 72 | 2. | 2 22.5 30.5 40.5 45 51 58.5 64 72 78 | 3. | 3 22.5 28 36.5 41 47.5 55 61 68 76 | 4. | 4 24 31.5 39.5 44.5 51 56 59.5 64 67 | 5. | 5 24.5 31.5 37 42.5 48 54 58 63 65.5 | +----------------------------------------------------------------------------+ . describe Contains data from C:\Documents and Settings\student\Desktop\Lab1\pigs.dta obs: 48 vars: 10 26 Jan 2005 09:40 size: 2,112 (99.8% of memory free) ------------------------------------------------------------------------------- storage display value variable name type format label variable label ------------------------------------------------------------------------------- id float %9.0g week1 float %9.0g week week2 float %9.0g week3 float %9.0g week4 float %9.0g week5 float %9.0g week6 float %9.0g week7 float %9.0g week8 float %9.0g week9 float %9.0g ------------------------------------------------------------------------------- Sorted by: Note: dataset has changed since last saved . save "C:\Documents and Settings\student\Desktop\Lab1\pigs.dta", replace file C:\Documents and Settings\student\Desktop\Lab1\pigs.dta saved . run "C:\DOCUME~1\student\LOCALS~1\Temp\STD050000.tmp" 1 invalid name r(198); . run "C:\DOCUME~1\student\LOCALS~1\Temp\STD050000.tmp" visit already defined r(110); . run "C:\DOCUME~1\student\LOCALS~1\Temp\STD050000.tmp" . l +-------------------+ | id visit week | |-------------------| 1. | 1 1 24 | 2. | 1 2 32 | 3. | 1 3 39 | 4. | 1 4 42.5 | 5. | 1 5 48 | |-------------------| 6. | 1 6 54.5 | 7. | 1 7 61 | 8. | 1 8 65 | 9. | 1 9 72 | 10. | 2 1 22.5 | |-------------------| 11. | 2 2 30.5 | 12. | 2 3 40.5 | 13. | 2 4 45 | 14. | 2 5 51 | 15. | 2 6 58.5 | |-------------------| 16. | 2 7 64 | 17. | 2 8 72 | 18. | 2 9 78 | 19. | 3 1 22.5 | 20. | 3 2 28 | |-------------------| 21. | 3 3 36.5 | 22. | 3 4 41 | 23. | 3 5 47.5 | 24. | 3 6 55 | 25. | 3 7 61 | |-------------------| 26. | 3 8 68 | 27. | 3 9 76 | 28. | 4 1 24 | 29. | 4 2 31.5 | 30. | 4 3 39.5 | |-------------------| 31. | 4 4 44.5 | 32. | 4 5 51 | 33. | 4 6 56 | 34. | 4 7 59.5 | 35. | 4 8 64 | |-------------------| 36. | 4 9 67 | 37. | 5 1 24.5 | 38. | 5 2 31.5 | 39. | 5 3 37 | 40. | 5 4 42.5 | |-------------------| 41. | 5 5 48 | 42. | 5 6 54 | 43. | 5 7 58 | 44. | 5 8 63 | 45. | 5 9 65.5 | |-------------------| 46. | 6 1 23 | 47. | 6 2 30 | 48. | 6 3 35.5 | 49. | 6 4 41 | 50. | 6 5 48 | |-------------------| 51. | 6 6 51.5 | 52. | 6 7 56.5 | 53. | 6 8 63.5 | 54. | 6 9 69.5 | 55. | 7 1 22.5 | |-------------------| 56. | 7 2 28.5 | 57. | 7 3 36 | 58. | 7 4 43.5 | 59. | 7 5 47 | 60. | 7 6 53.5 | |-------------------| 61. | 7 7 59.5 | 62. | 7 8 67.5 | 63. | 7 9 73.5 | 64. | 8 1 23.5 | 65. | 8 2 30.5 | |-------------------| 66. | 8 3 38 | 67. | 8 4 41 | 68. | 8 5 48.5 | 69. | 8 6 55 | 70. | 8 7 59.5 | |-------------------| 71. | 8 8 66.5 | 72. | 8 9 73 | 73. | 9 1 20 | 74. | 9 2 27.5 | 75. | 9 3 33 | |-------------------| 76. | 9 4 39 | 77. | 9 5 43.5 | 78. | 9 6 49 | 79. | 9 7 54.5 | 80. | 9 8 59.5 | |-------------------| 81. | 9 9 65 | 82. | 10 1 25.5 | 83. | 10 2 32.5 | 84. | 10 3 39.5 | 85. | 10 4 47 | |-------------------| 86. | 10 5 53 | 87. | 10 6 58.5 | 88. | 10 7 63 | 89. | 10 8 69.5 | 90. | 10 9 76 | |-------------------| 91. | 11 1 24.5 | 92. | 11 2 31 | 93. | 11 3 40.5 | 94. | 11 4 46 | 95. | 11 5 51.5 | |-------------------| 96. | 11 6 57 | 97. | 11 7 62.5 | 98. | 11 8 69.5 | 99. | 11 9 76 | 100. | 12 1 24 | |-------------------| 101. | 12 2 29 | 102. | 12 3 39 | 103. | 12 4 44 | 104. | 12 5 50.5 | 105. | 12 6 57 | |-------------------| 106. | 12 7 61.5 | 107. | 12 8 68 | 108. | 12 9 73.5 | 109. | 13 1 23.5 | 110. | 13 2 30.5 | |-------------------| 111. | 13 3 36.5 | 112. | 13 4 42 | 113. | 13 5 47 | 114. | 13 6 55 | 115. | 13 7 59 | |-------------------| 116. | 13 8 65.5 | 117. | 13 9 73 | 118. | 14 1 21.5 | 119. | 14 2 30.5 | 120. | 14 3 37 | |-------------------| 121. | 14 4 42.5 | 122. | 14 5 48 | 123. | 14 6 52.5 | 124. | 14 7 58.5 | 125. | 14 8 63 | |-------------------| 126. | 14 9 69.5 | 127. | 15 1 25 | 128. | 15 2 32 | 129. | 15 3 38.5 | 130. | 15 4 44 | |-------------------| 131. | 15 5 51 | 132. | 15 6 59 | 133. | 15 7 66 | 134. | 15 8 75.5 | 135. | 15 9 86 | |-------------------| 136. | 16 1 21.5 | 137. | 16 2 28.5 | 138. | 16 3 34 | 139. | 16 4 39.5 | 140. | 16 5 45 | |-------------------| 141. | 16 6 51 | 142. | 16 7 58 | 143. | 16 8 64.5 | 144. | 16 9 72.5 | 145. | 17 1 31 | |-------------------| 146. | 17 2 38 | 147. | 17 3 48 | 148. | 17 4 54 | 149. | 17 5 60 | 150. | 17 6 62 | |-------------------| 151. | 17 7 66.5 | 152. | 17 8 75.5 | 153. | 17 9 84 | 154. | 18 1 27.5 | 155. | 18 2 32.5 | |-------------------| 156. | 18 3 36 | 157. | 18 4 43 | 158. | 18 5 49.5 | 159. | 18 6 52.5 | 160. | 18 7 56 | |-------------------| 161. | 18 8 61 | 162. | 18 9 64 | 163. | 19 1 30 | 164. | 19 2 37 | 165. | 19 3 45 | |-------------------| 166. | 19 4 51 | 167. | 19 5 58 | 168. | 19 6 63 | 169. | 19 7 67.5 | 170. | 19 8 74.5 | |-------------------| 171. | 19 9 81 | 172. | 20 1 26 | 173. | 20 2 32 | 174. | 20 3 40.5 | 175. | 20 4 45.5 | |-------------------| 176. | 20 5 52.5 | 177. | 20 6 55.5 | 178. | 20 7 62.5 | 179. | 20 8 69.5 | 180. | 20 9 74 | |-------------------| 181. | 21 1 26 | 182. | 21 2 32.5 | 183. | 21 3 39.5 | 184. | 21 4 44 | 185. | 21 5 48 | |-------------------| 186. | 21 6 54.5 | 187. | 21 7 58 | 188. | 21 8 66 | 189. | 21 9 73 | 190. | 22 1 28.5 | |-------------------| 191. | 22 2 35.5 | 192. | 22 3 41.5 | 193. | 22 4 47.5 | 194. | 22 5 54 | 195. | 22 6 59.5 | |-------------------| 196. | 22 7 63.5 | 197. | 22 8 71 | 198. | 22 9 78.5 | 199. | 23 1 26.5 | 200. | 23 2 34.5 | |-------------------| 201. | 23 3 42 | 202. | 23 4 48.5 | 203. | 23 5 55.5 | 204. | 23 6 62 | 205. | 23 7 68 | |-------------------| 206. | 23 8 76.5 | 207. | 23 9 85 | 208. | 24 1 27.5 | 209. | 24 2 33.5 | 210. | 24 3 41 | |-------------------| 211. | 24 4 45 | 212. | 24 5 50.5 | 213. | 24 6 56 | 214. | 24 7 62.5 | 215. | 24 8 71 | |-------------------| 216. | 24 9 78 | 217. | 25 1 22.5 | 218. | 25 2 27 | 219. | 25 3 33.5 | 220. | 25 4 38.5 | |-------------------| 221. | 25 5 41 | 222. | 25 6 49 | 223. | 25 7 56 | 224. | 25 8 64 | 225. | 25 9 68 | |-------------------| 226. | 26 1 22 | 227. | 26 2 26.5 | 228. | 26 3 32.5 | 229. | 26 4 38.5 | 230. | 26 5 43.5 | |-------------------| 231. | 26 6 50.5 | 232. | 26 7 56.5 | 233. | 26 8 63.5 | 234. | 26 9 68.5 | 235. | 27 1 23.5 | |-------------------| 236. | 27 2 29 | 237. | 27 3 35.5 | 238. | 27 4 40 | 239. | 27 5 45 | 240. | 27 6 50 | |-------------------| 241. | 27 7 56.5 | 242. | 27 8 63 | 243. | 27 9 67.5 | 244. | 28 1 22.5 | 245. | 28 2 29.5 | |-------------------| 246. | 28 3 36.5 | 247. | 28 4 42 | 248. | 28 5 45 | 249. | 28 6 55 | 250. | 28 7 61 | |-------------------| 251. | 28 8 68 | 252. | 28 9 72 | 253. | 29 1 27.5 | 254. | 29 2 34.5 | 255. | 29 3 42 | |-------------------| 256. | 29 4 47.5 | 257. | 29 5 53 | 258. | 29 6 63 | 259. | 29 7 72 | 260. | 29 8 79 | |-------------------| 261. | 29 9 85.5 | 262. | 30 1 23.5 | 263. | 30 2 28 | 264. | 30 3 33 | 265. | 30 4 37 | |-------------------| 266. | 30 5 38.5 | 267. | 30 6 48 | 268. | 30 7 52.5 | 269. | 30 8 62 | 270. | 30 9 64.5 | |-------------------| 271. | 31 1 24.5 | 272. | 31 2 30 | 273. | 31 3 38.5 | 274. | 31 4 42 | 275. | 31 5 47.5 | |-------------------| 276. | 31 6 54 | 277. | 31 7 62.5 | 278. | 31 8 71.5 | 279. | 31 9 77 | 280. | 32 1 24.5 | |-------------------| 281. | 32 2 31.5 | 282. | 32 3 40.5 | 283. | 32 4 46.5 | 284. | 32 5 51.5 | 285. | 32 6 61.5 | |-------------------| 286. | 32 7 68.5 | 287. | 32 8 77.5 | 288. | 32 9 84.5 | 289. | 33 1 24.5 | 290. | 33 2 32 | |-------------------| 291. | 33 3 39 | 292. | 33 4 45 | 293. | 33 5 51 | 294. | 33 6 55.5 | 295. | 33 7 61.5 | |-------------------| 296. | 33 8 69 | 297. | 33 9 75.5 | 298. | 34 1 24 | 299. | 34 2 32.5 | 300. | 34 3 40 | |-------------------| 301. | 34 4 48 | 302. | 34 5 54.5 | 303. | 34 6 61.5 | 304. | 34 7 68 | 305. | 34 8 74.5 | |-------------------| 306. | 34 9 81 | 307. | 35 1 24 | 308. | 35 2 31.5 | 309. | 35 3 38.5 | 310. | 35 4 44 | |-------------------| 311. | 35 5 51.5 | 312. | 35 6 57.5 | 313. | 35 7 64 | 314. | 35 8 72.5 | 315. | 35 9 79 | |-------------------| 316. | 36 1 24.5 | 317. | 36 2 32.5 | 318. | 36 3 39.5 | 319. | 36 4 44.5 | 320. | 36 5 52.5 | |-------------------| 321. | 36 6 56.5 | 322. | 36 7 62 | 323. | 36 8 67.5 | 324. | 36 9 72.5 | 325. | 37 1 24.5 | |-------------------| 326. | 37 2 32 | 327. | 37 3 38.5 | 328. | 37 4 44 | 329. | 37 5 50 | 330. | 37 6 56 | |-------------------| 331. | 37 7 63.5 | 332. | 37 8 69.5 | 333. | 37 9 76 | 334. | 38 1 25.5 | 335. | 38 2 33 | |-------------------| 336. | 38 3 41.5 | 337. | 38 4 47 | 338. | 38 5 55.5 | 339. | 38 6 60.5 | 340. | 38 7 66.5 | |-------------------| 341. | 38 8 77 | 342. | 38 9 82 | 343. | 39 1 25.5 | 344. | 39 2 32 | 345. | 39 3 39 | |-------------------| 346. | 39 4 45.5 | 347. | 39 5 51 | 348. | 39 6 57.5 | 349. | 39 7 63.5 | 350. | 39 8 72 | |-------------------| 351. | 39 9 78.5 | 352. | 40 1 25 | 353. | 40 2 31 | 354. | 40 3 36.5 | 355. | 40 4 43 | |-------------------| 356. | 40 5 50.5 | 357. | 40 6 55 | 358. | 40 7 62.5 | 359. | 40 8 69 | 360. | 40 9 75.5 | |-------------------| 361. | 41 1 26.5 | 362. | 41 2 30.5 | 363. | 41 3 33 | 364. | 41 4 39 | 365. | 41 5 43.5 | |-------------------| 366. | 41 6 49.5 | 367. | 41 7 56.5 | 368. | 41 8 61 | 369. | 41 9 65 | 370. | 42 1 24 | |-------------------| 371. | 42 2 32 | 372. | 42 3 39 | 373. | 42 4 44.5 | 374. | 42 5 50 | 375. | 42 6 56 | |-------------------| 376. | 42 7 63 | 377. | 42 8 67.5 | 378. | 42 9 74 | 379. | 43 1 24.5 | 380. | 43 2 31 | |-------------------| 381. | 43 3 37.5 | 382. | 43 4 43.5 | 383. | 43 5 48 | 384. | 43 6 56 | 385. | 43 7 62.5 | |-------------------| 386. | 43 8 66.5 | 387. | 43 9 70.5 | 388. | 44 1 27 | 389. | 44 2 34.5 | 390. | 44 3 42 | |-------------------| 391. | 44 4 48.5 | 392. | 44 5 53 | 393. | 44 6 60 | 394. | 44 7 67 | 395. | 44 8 73 | |-------------------| 396. | 44 9 76 | 397. | 45 1 31 | 398. | 45 2 39 | 399. | 45 3 47.5 | 400. | 45 4 51 | |-------------------| 401. | 45 5 57 | 402. | 45 6 64 | 403. | 45 7 71 | 404. | 45 8 77 | 405. | 45 9 80.5 | |-------------------| 406. | 46 1 27 | 407. | 46 2 33.5 | 408. | 46 3 40 | 409. | 46 4 46.5 | 410. | 46 5 53 | |-------------------| 411. | 46 6 60 | 412. | 46 7 66.5 | 413. | 46 8 72.5 | 414. | 46 9 80 | 415. | 47 1 29.5 | |-------------------| 416. | 47 2 37 | 417. | 47 3 46 | 418. | 47 4 52.5 | 419. | 47 5 60 | 420. | 47 6 67.5 | |-------------------| 421. | 47 7 76 | 422. | 47 8 81.5 | 423. | 47 9 88 | 424. | 48 1 28.5 | 425. | 48 2 36 | |-------------------| 426. | 48 3 42.5 | 427. | 48 4 49 | 428. | 48 5 55 | 429. | 48 6 63.5 | 430. | 48 7 72 | |-------------------| 431. | 48 8 78.5 | 432. | 48 9 85.5 | +-------------------+ . twoway line week visit, s(i) . graph save "C:\Documents and Settings\student\Desktop\Lab1\fig1.3.gph", replace (note: file C:\Documents and Settings\student\Desktop\Lab1\fig1.3.gph not found) (file C:\Documents and Settings\student\Desktop\Lab1\fig1.3.gph saved) . graph save "C:\Documents and Settings\student\Desktop\Lab1\fig13.gph", replace (note: file C:\Documents and Settings\student\Desktop\Lab1\fig13.gph not found) (file C:\Documents and Settings\student\Desktop\Lab1\fig13.gph saved) . graph save "C:\Documents and Settings\student\Desktop\Lab1\newg.gph", replace (note: file C:\Documents and Settings\student\Desktop\Lab1\newg.gph not found) (file C:\Documents and Settings\student\Desktop\Lab1\newg.gph saved) . reshape wide (note: j = 1 2 3 4 5 6 7 8 9) Data long -> wide ----------------------------------------------------------------------------- Number of obs. 432 -> 48 Number of variables 3 -> 10 j variable (9 values) visit -> (dropped) xij variables: week -> week1 week2 ... week9 ----------------------------------------------------------------------------- . summarize week1-week9 Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- week1 | 48 25.02083 2.468866 20 31 week2 | 48 31.78125 2.790383 26.5 39 week3 | 48 38.86458 3.544158 32.5 48 week4 | 48 44.39583 3.734483 37 54 week5 | 48 50.15625 4.534919 38.5 60 -------------+-------------------------------------------------------- week6 | 48 56.44792 4.449766 48 67.5 week7 | 48 62.45833 4.973155 52.5 76 week8 | 48 69.30208 5.424275 59.5 81.5 week9 | 48 75.21875 6.335401 64 88 . run "C:\DOCUME~1\student\LOCALS~1\Temp\STD050000.tmp" too many ')' or ']' r(132); . run "C:\DOCUME~1\student\LOCALS~1\Temp\STD050000.tmp" . run "C:\DOCUME~1\student\LOCALS~1\Temp\STD050000.tmp" . reshape long week sweek, i(id) j(visit) (note: j = 1 2 3 4 5 6 7 8 9) Data wide -> long ----------------------------------------------------------------------------- Number of obs. 48 -> 432 Number of variables 37 -> 22 j variable (9 values) -> visit xij variables: week1 week2 ... week9 -> week sweek1 sweek2 ... sweek9 -> sweek ----------------------------------------------------------------------------- . move sweek m1 . sort id visit . twoway line sweek visit, s(i) . drop m1 . twoway line sweek visit, s(i) . edit - preserve . edit - preserve . reshape wide (note: j = 1 2 3 4 5 6 7 8 9) Data long -> wide ----------------------------------------------------------------------------- Number of obs. 432 -> 48 Number of variables 21 -> 36 j variable (9 values) visit -> (dropped) xij variables: week -> week1 week2 ... week9 sweek -> sweek1 sweek2 ... sweek9 ----------------------------------------------------------------------------- . reshape long week s, i(id) j(visit) (note: j = 1 2 3 4 5 6 7 8 9) Data wide -> long ----------------------------------------------------------------------------- Number of obs. 48 -> 432 Number of variables 36 -> 21 j variable (9 values) -> visit xij variables: week1 week2 ... week9 -> week s1 s2 ... s9 -> s ----------------------------------------------------------------------------- . sort id visit . twoway line sweek visit, s(i) sweek ambiguous abbreviation no variables defined r(111); . twoway line s visit, s(i) . regress week time variable time not found r(111); . regress week visit Source | SS df MS Number of obs = 432 -------------+------------------------------ F( 1, 430) = 5757.41 Model | 111060.882 1 111060.882 Prob > F = 0.0000 Residual | 8294.72677 430 19.2900622 R-squared = 0.9305 -------------+------------------------------ Adj R-squared = 0.9303 Total | 119355.609 431 276.927167 Root MSE = 4.392 ------------------------------------------------------------------------------ week | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- visit | 6.209896 .0818409 75.88 0.000 6.049038 6.370754 _cons | 19.35561 .4605447 42.03 0.000 18.45041 20.26081 ------------------------------------------------------------------------------ . loc close . exit, clear