-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrite_var.ado
578 lines (501 loc) · 19.2 KB
/
write_var.ado
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
program define write_var
syntax varlist, pvar(string) tvar(string) tccheck(string) [keepmd] [verbose]
************************************* verbose ********************************************
if "`verbose'" == "verbose" {
di ""
di "------------------------ begin write_var.ado ----------------------------"
di ""
di "Time analysis for `varlist'"
}
******************************************************************************************
local var = "`varlist'"
if regexm(`"`tccheck'"',"fillin") == 1 {
local fillin = "fillin"
local tccheck = regexr(`"`tccheck'"',"fillin","")
}
else {
local fillin = ""
}
if regexm(`"`tccheck'"',"rlvc") == 1 {
local rlvc = "rlvc"
local tccheck = regexr(`"`tccheck'"',"rlvc","")
}
else {
local rlvc = ""
}
if "`verbose'" == "verbose" {
di ""
di "Program readtccheck"
}
readtccheck, tccheck(`tccheck') `verbose'
/*
if "`r(graph)'" == "none" {
local graph = ""
}
else {
local graph = "`r(graph)'"
}*/
if "`r(unit)'" == "none" {
local unit = 0
}
else {
local unit = `r(unit)'
}
if "`r(by)'" == "none" {
local by = ""
}
else {
local by = "`r(by)'"
}
if "`r(step)'" == "none" {
local step = 1
}
else {
local step = `r(step)'
}
if "`r(langle)'" == "none" {
local langle = 180
}
else {
local langle = `r(langle)'
}
if "`r(yangle)'" == "none" {
local yangle = 0
}
else {
local yangle = `r(yangle)'
}
if "`r(den)'" == "none" {
local den = 1
}
else {
local den = `r(den)'
}
if "`r(flow)'" == "none" {
local flow = ""
}
else {
local flow = "`r(flow)'"
}
if "`r(thr)'" == "none" {
local thr = 30
}
else {
local thr = `r(thr)'
}
if `"`r(save)'"' == "none" {
local save = ""
}
else {
local save = `"`r(save)'"'
}
if "`r(rows)'" == "none" {
local rows = 3
}
else {
local rows = `r(rows)'
}
if "`r(ptrn)'" == "none" {
local ptrn = ""
}
else {
local ptrn = "`r(ptrn)'"
}
// rownames to use when using ado exceltomata
levelsof(`tvar'), local(levels)
local lc: word count `levels'
forvalues i=1/`lc' {
local rown = "`rown'" + " `i'"
}
//di "`rown'"
local di_unit = "10^`unit'"
capture file close myfile1
// ` !
// ' ?
// " §
// ! £
// § @
// Number of observations
file open myfile1 using "`var'_write.stmd", write text replace
file write myfile1 "<meta charset=§utf-8§/>" _n
file write myfile1 _n
local labelvar: var label `var'
file write myfile1 "# <span style=§color:black§>**Time analysis for `labelvar' (`var')**</span>" _n
file write myfile1 _n
file write myfile1 "## Dataset: `s §${dta_file}§`" _n
file write myfile1 "## Date: `s §`c(current_date)'§`"_n
file write myfile1 "## Time: `s §`c(current_time)'§`"_n
file write myfile1 _n
file write myfile1 "!!!s/" _n
file write myfile1 "local lc = `lc'" _n
file write myfile1 "capture mkdir graphs" _n
file write myfile1 "!!!" _n
if "`graph'" == "rel" {
file write myfile1 "### Mean and median over time (%)" _n
}
else {
file write myfile1 "### Mean and median over time (`di_unit')" _n
}
file write myfile1 _n
file write myfile1 "!!!s/" _n
file write myfile1 "preserve" _n
file write myfile1 "if §`rlvc'§ == §rlvc§ {" _n
if "`verbose'" == "verbose" {
di ""
di "Graphs for mean and median over time (relative changes)"
}
file write myfile1 "qui gen double rel_`var'=100*(`var'-l.`var')/(abs(`var'+l.`var')/2)" _n
file write myfile1 "*To avoid near zero differences in the denominator" _n
file write myfile1 "quietly replace rel_`var'=. if abs(`var'+l.`var')<1" _n
file write myfile1 "gcollapse (mean) mean_`var'=rel_`var' (p50) median_`var'=rel_`var', by (`tvar')" _n
file write myfile1 "label var mean_`var' §Mean (%)§" _n
file write myfile1 "label var median_`var' §Median (%)§" _n
file write myfile1 "}" _n
file write myfile1 "else {" _n
if "`verbose'" == "verbose" {
di ""
di "Graphs for mean and median over time (levels)"
}
file write myfile1 "gcollapse (mean) mean_`var'=`var' (p50) median_`var'=`var', by (`tvar')" _n
file write myfile1 "quietly replace mean_`var' = mean_`var'/10^`unit'" _n
file write myfile1 "quietly replace median_`var' = median_`var'/10^`unit'" _n
file write myfile1 "label var mean_`var' §Mean§" _n
file write myfile1 "label var median_`var' §Median§" _n
file write myfile1 "}" _n
file write myfile1 "quietly line mean_`var' `tvar'" _n
file write myfile1 "quietly graph save graphs/mean_`var', replace" _n
file write myfile1 "quietly line median_`var' `tvar'" _n
file write myfile1 "quietly graph save graphs/median_`var', replace" _n
file write myfile1 "graph combine §graphs/mean_`var'.gph§ §graphs/median_`var'.gph§" _n
file write myfile1 "quietly graph export graphs/mean_median_`var'.png, replace" _n
file write myfile1 "quietly capture rm graphs/mean_`var'.gph" _n
file write myfile1 "quietly capture rm graphs/median_`var'.gph" _n
file write myfile1 "restore" _n
file write myfile1 "!!!" _n
file write myfile1 _n
file write myfile1 "£[](graphs/mean_median_`var'.png){width=§40%§}" _n
file write myfile1 _n
/*
file write myfile1 "!!!s/" _n
file write myfile1 "capture rm graphs/mean_`var'.gph" _n
file write myfile1 "capture rm graphs/median_`var'.gph" _n
file write myfile1 "capture rm graphs/mean_median_`var'.png" _n
file write myfile1 "!!!" _n
*/
* Relative changes overtime
if "`verbose'" == "verbose" {
di ""
di "Relative changes over time"
di ""
di "command: quietly panelstat `pvar' `tvar', nosum rel(`var',keep)"
}
file write myfile1 _n
file write myfile1 "### Relative changes over time" _n
file write myfile1 _n
file write myfile1 "!!!s/" _n
file write myfile1 "quietly panelstat `pvar' `tvar', nosum rel(`var',keep)" _n
if "`verbose'" == "verbose" {
di ""
di "Program tcompmat"
}
file write myfile1 "tcompmat _rel_L1_`var', levels(1 2 3 4 5 6) `verbose'" _n
// abs freq
file write myfile1 "mat z = r(x)" _n
// total
file write myfile1 "mata : st_matrix(§ztot§, rowsum(st_matrix(§z§)))" _n
file write myfile1 "mat z = z,ztot[1,1]" _n
file write myfile1 "mat z = z?" _n
// rel freq
file write myfile1 "mat y = J(7,1,0)" _n
file write myfile1 "quietly forvalues i = 1/7 {" _n
file write myfile1 "quietly mat y[!i?,1] = z[!i?,1]/z[7,1]*100" _n
file write myfile1 "}" _n
// cumulative freq
file write myfile1 "mat x = J(6,1,0)" _n
file write myfile1 "local cum = 0" _n
file write myfile1 "quietly forvalues i = 1/6 {" _n
file write myfile1 "quietly mat x[!i?,1] = y[!i?,1] + !cum?" _n
file write myfile1 "quietly local cum = x[!i?,1]" _n
file write myfile1 "}" _n
file write myfile1 "mat x = x\100" _n
file write myfile1 _n
// final matrix
file write myfile1 "mat rel = z,y,x" _n
file write myfile1 `"mat rownames rel = "Positive change" "Negative change" "No change" "Abnormal positive change" "Abnormal negative change" "Missing" "Total""' _n
file write myfile1 "mat colnames rel = Freq. Percent Cum." _n
file write myfile1 "matprint rel, decimals(0,2,2)" _n
file write myfile1 "di §§" _n
file write myfile1 "di §Abnormal relative changes by `tvar'§" _n
file write myfile1 "di §§" _n
file write myfile1 "tab _rel_L1_`var' `tvar' if _rel_L1_`var' == 4 | _rel_L1_`var' == 5" _n
file write myfile1 "quietly drop _rel_L1_`var'" _n
file write myfile1 "!!!" _n
* Time flows
if "`verbose'" == "verbose" {
di ""
di "Time flows"
di ""
di "command: quietly panelstat `pvar' `tvar', nosum flows(`var', unit) excel(graphs/`var'flow, replace)"
}
file write myfile1 "### Time flows (`di_unit')" _n
file write myfile1 _n
file write myfile1 "!!!s/" _n
file write myfile1 "quietly panelstat `pvar' `tvar', nosum flows(`var', unit) excel(graphs/`var'flow, replace)" _n
file write myfile1 "local fr = 3+!lc?" _n
if "`verbose'" == "verbose" {
di ""
di "Program exceltomata"
}
file write myfile1 "exceltomata, file(graphs/`var'flow.xlsx) ir(4) fr(!fr?) ic(1) fc(10) ii(3) `verbose'" _n
file write myfile1 "mat B = r(x)" _n
file write myfile1 "mat B1 = B[.,1..1],B[.,2..10]/10^`unit'" _n
file write myfile1 "matrix colnames B1 = time `var' chg chg_inc expansion contraction entry exit miss_1 miss_2" _n
file write myfile1 "matrix rownames B1 = `rown'" _n
file write myfile1 "matprint B1, decimals(0,2,2)" _n
file write myfile1 "di §§" _n
file write myfile1 "di §Notes:§" _n
file write myfile1 "di §`var' - total sum of `var' at time t§" _n
file write myfile1 "di §chg - sum of `var' at t minus t-1§" _n
file write myfile1 "di §chg_inc - changes from individuals present at t and at t-1 with valid values of `var'§" _n
file write myfile1 "di § of which:§" _n
file write myfile1 "di § expansion - positive changes (expansions) from individuals present at t and at t-1§" _n
file write myfile1 "di § contraction - negative changes (contractions) from individuals present at t and at t-1§" _n
file write myfile1 "di §entry - change resulting from entry (present at t but not at t-1)§" _n
file write myfile1 "di §exit - change resulting from exits (present at t-1 but not at t)§" _n
file write myfile1 "di §miss_1 - change from individuals present at t and t-1 but with missing data at t-1§" _n
file write myfile1 "di §miss_2 - change from individuals present at t and t-1 but with missing data at t§" _n
file write myfile1 "di §`var'[t]=`var'[t-1]+chg, chg=chg_inc+entry+exit+miss_1+miss_2, chg_inc=expansion+contraction§" _n
file write myfile1 "di §§" _n
file write myfile1 "di §Valid observations for `var'§" _n
file write myfile1 "di §§" _n
file write myfile1 "local fr = 3+!lc?" _n
if "`verbose'" == "verbose" {
di ""
di "Program exceltomata"
}
file write myfile1 "exceltomata, file(graphs/`var'flow.xlsx) ir(4) fr(!fr?) ic(12) fc(21) ii(3) ij(11) `verbose'" _n
file write myfile1 "capture rm graphs/`var'flow.xlsx" _n
file write myfile1 "matrix C = r(x)" _n
file write myfile1 "matrix colnames C = time n_var n_miss n_inc0 n_exp n_cont n_ent0 n_exi0 n_inc1 n_inc2" _n
file write myfile1 "matrix rownames C = `rown'" _n
file write myfile1 "matprint C, decimals(0,0,0)" _n
file write myfile1 "di §§" _n
file write myfile1 "di §Notes:§" _n
file write myfile1 "di §n_var - total number of nonmissing values of `var' at time t§" _n
file write myfile1 "di §n_miss - number of missing values of `var' at time t§" _n
file write myfile1 "di §n_inc0 - number of observations with nonmissing values at t and t-1 (incumbents)§" _n
file write myfile1 "di § of which:§" _n
file write myfile1 "di § n_exp - number of incumbents that increased `var' from time t-1 to t§" _n
file write myfile1 "di § n_cont - number of incumbents that decreased `var' from time t-1 to t§" _n
file write myfile1 "di §n_ent0 - number of entrants with nonmissing values of `var'§" _n
file write myfile1 "di §n_exi0 - number of exits with nonmissing values of `var'§" _n
file write myfile1 "di §n_inc1 - number of incumbents with missing values of `var' at t-1 only§" _n
file write myfile1 "di §n_inc2 - number of incumbents with missing values of `var' at t only§" _n
file write myfile1 "!!!" _n
file write myfile1 _n
* Regression of var on years
if "`verbose'" == "verbose" {
di ""
di "Regression of `var' on `tvar'"
}
file write myfile1 "### Regression of `var' on `tvar'" _n
file write myfile1 _n
file write myfile1 "!!!s/" _n
file write myfile1 "reg `var' i.`tvar', noheader" _n
file write myfile1 "!!!" _n
* Time consistency analysis
if "`verbose'" == "verbose" {
di ""
di "Time consistency analysis"
}
if `"`tccheck'"' != "" {
if "`by'" == "" {
file write myfile1 "### Time consistency analysis of `var' (`di_unit')" _n
}
else {
if "`flow'" == "" {
file write myfile1 "### Time consistency analysis of `var' (mean) by `by' (`di_unit')" _n
}
else {
file write myfile1 "### Time consistency analysis of `var' (`flow') by `by' (`di_unit')" _n
}
}
if "`ptrn'" == "" {
file write myfile1 "#### Pattern 1: captures relative changes above the threshold specified by the user (`thr' %)" _n
file write myfile1 _n
file write myfile1 "!!!s/"_n
file write myfile1 "preserve"_n
file write myfile1 "if `unit' > 0 {" _n
file write myfile1 "quietly replace `var' = `var'/10^`unit'" _n
file write myfile1 "}" _n
if "`verbose'" == "verbose" {
di ""
di "Program tccheck1"
}
file write myfile1 "quietly tccheck1 `var', pvar(`pvar') tvar(`tvar') by(`by') step(`step') langle(`langle') yangle(`yangle') flow(`flow') thr(`thr') save(`save') `fillin' `verbose'" _n
file write myfile1 "restore"_n
file write myfile1 "!!!"
if "`by'" == "" {
file write myfile1 _n
file write myfile1 "£[](graphs/tc1_`var'.png)" _n //{width=§40%§}
}
else {
file write myfile1 _n
file write myfile1 "!!!s/"_n
file write myfile1 "preserve"_n
file write myfile1 "quietly drop if missing(`by') " _n
file write myfile1 "quietly glevelsof(`by'), local(levels)" _n
file write myfile1 "quietly foreach item in !levels? {" _n
file write myfile1 `"quietly local gcommand1 = "!gcommand1?" + " tc1_`var'_`by'_!item?.gph""' _n
file write myfile1 "}"_n
file write myfile1 "quietly graph combine !gcommand1?, rows(`rows')"_n
file write myfile1 "quietly graph export graphs/tc1_`var'_`by'.png, replace" _n
file write myfile1 "quietly foreach item in !levels? {" _n
file write myfile1 "quietly capture rm tc1_`var'_`by'_!item?.gph" _n
file write myfile1 "}"_n
file write myfile1 "restore"_n
file write myfile1 "!!!"_n
file write myfile1 "£[](graphs/tc1_`var'_`by'.png)" _n //{width=§40%§}
}
file write myfile1 _n
file write myfile1 "#### Pattern 2: captures relative increases (decreases) above the threshold followed by a `tvar' (consecutive or non-consecutive) with a relative decrease (increase) above the threshold (`thr' %)" _n
file write myfile1 _n
file write myfile1 "!!!s/"_n
file write myfile1 "preserve"_n
file write myfile1 "if `unit' > 0 {" _n
file write myfile1 "quietly replace `var' = `var'/10^`unit'" _n
file write myfile1 "}" _n
if "`verbose'" == "verbose" {
di ""
di "Program tccheck2"
}
file write myfile1 "quietly tccheck2 `var', pvar(`pvar') tvar(`tvar') by(`by') step(`step') langle(`langle') yangle(`yangle') flow(`flow') thr(`thr') save(`save') `fillin' `verbose'" _n
file write myfile1 "restore"_n
file write myfile1 "!!!"
if "`by'" == "" {
file write myfile1 _n
file write myfile1 "£[](graphs/tc2_`var'.png)" _n //{width=§40%§}
}
else {
file write myfile1 _n
file write myfile1 "!!!s/"_n
file write myfile1 "preserve"_n
file write myfile1 "quietly drop if missing(`by') " _n
file write myfile1 "quietly glevelsof(`by'), local(levels)" _n
file write myfile1 "quietly foreach item in !levels? {" _n
file write myfile1 `"quietly local gcommand2 = "!gcommand2?" + " tc2_`var'_`by'_!item?.gph""' _n
file write myfile1 "}"_n
file write myfile1 "quietly graph combine !gcommand2?, rows(`rows')"_n
file write myfile1 "quietly graph export graphs/tc2_`var'_`by'.png, replace" _n
file write myfile1 "quietly foreach item in !levels? {" _n
file write myfile1 "quietly capture rm tc2_`var'_`by'_!item?.gph" _n
file write myfile1 "}"_n
file write myfile1 "restore"_n
file write myfile1 "!!!"_n
file write myfile1 "£[](graphs/tc2_`var'_`by'.png)" _n //{width=§40%§}
}
}
else if "`ptrn'" == "1" {
file write myfile1 "#### Pattern 1: captures relative changes above the threshold specified by the user (`thr' %)" _n
file write myfile1 _n
file write myfile1 "!!!s/"_n
file write myfile1 "preserve"_n
file write myfile1 "if `unit' > 0 {" _n
file write myfile1 "quietly replace `var' = `var'/10^`unit'" _n
file write myfile1 "}" _n
if "`verbose'" == "verbose" {
di ""
di "Program tccheck1"
}
file write myfile1 "quietly tccheck1 `var', pvar(`pvar') tvar(`tvar') by(`by') step(`step') langle(`langle') yangle(`yangle') flow(`flow') thr(`thr') save(`save') `fillin' `verbose'" _n
file write myfile1 "restore"_n
file write myfile1 "!!!"
if "`by'" == "" {
file write myfile1 _n
file write myfile1 "£[](graphs/tc1_`var'.png)" _n //{width=§40%§}
}
else {
file write myfile1 _n
file write myfile1 "!!!s/"_n
file write myfile1 "preserve"_n
file write myfile1 "quietly drop if missing(`by') " _n
file write myfile1 "quietly glevelsof(`by'), local(levels)" _n
file write myfile1 "quietly foreach item in !levels? {" _n
file write myfile1 `"quietly local gcommand = "!gcommand?" + " tc1_`var'_`by'_!item?.gph""' _n
file write myfile1 "}"_n
file write myfile1 "quietly graph combine !gcommand?, rows(`rows')"_n
file write myfile1 "quietly graph export graphs/tc1_`var'_`by'.png, replace" _n
file write myfile1 "quietly foreach item in !levels? {" _n
file write myfile1 "quietly capture rm tc1_`var'_`by'_!item?.gph" _n
file write myfile1 "}"_n
file write myfile1 "restore"_n
file write myfile1 "!!!"_n
file write myfile1 "£[](graphs/tc1_`var'_`by'.png)" _n //{width=§40%§}
}
}
else if "`ptrn'" == "2" {
file write myfile1 "#### Pattern 2: captures relative increases (decreases) above the threshold followed by a `tvar' (consecutive or non-consecutive) with a relative decrease (increase) above the threshold (`thr' %)" _n
file write myfile1 _n
file write myfile1 "!!!s/"_n
file write myfile1 "preserve"_n
file write myfile1 "if `unit' > 0 {" _n
file write myfile1 "quietly replace `var' = `var'/10^`unit'" _n
file write myfile1 "}" _n
if "`verbose'" == "verbose" {
di ""
di "Program tccheck1"
}
file write myfile1 "quietly tccheck2 `var', pvar(`pvar') tvar(`tvar') by(`by') step(`step') langle(`langle') yangle(`yangle') flow(`flow') thr(`thr') save(`save') `fillin' `verbose'" _n
file write myfile1 "restore"_n
file write myfile1 "!!!"
if "`by'" == "" {
file write myfile1 _n
file write myfile1 "£[](graphs/tc2_`var'.png)" _n //{width=§40%§}
}
else {
file write myfile1 _n
file write myfile1 "!!!s/"_n
file write myfile1 "preserve"_n
file write myfile1 "quietly drop if missing(`by') " _n
file write myfile1 "quietly glevelsof(`by'), local(levels)" _n
file write myfile1 "quietly foreach item in !levels? {" _n
file write myfile1 `"quietly local gcommand = "!gcommand?" + " tc2_`var'_`by'_!item?.gph""' _n
file write myfile1 "}"_n
file write myfile1 "quietly graph combine !gcommand?, rows(`rows')"_n
file write myfile1 "quietly graph export graphs/tc2_`var'_`by'.png, replace" _n
file write myfile1 "quietly foreach item in !levels? {" _n
file write myfile1 "quietly capture rm tc2_`var'_`by'_!item?.gph" _n
file write myfile1 "}"_n
file write myfile1 "restore"_n
file write myfile1 "!!!"_n
file write myfile1 "£[](graphs/tc2_`var'_`by'.png)" _n //{width=§40%§}
}
}
}
file close myfile1
filefilter `var'_write.stmd `var'_write1.stmd, from(!) to(\LQ) replace
filefilter `var'_write1.stmd `var'_write2.stmd, from(?) to(\RQ) replace
filefilter `var'_write2.stmd `var'_write3.stmd , from(§) to(\Q) replace
filefilter `var'_write3.stmd `var'_write4.stmd, from(£) to(!) replace
filefilter `var'_write4.stmd `var'_tmd.stmd, from(@) to(\$) replace
if "`verbose'" == "verbose" {
di ""
di "Using markstat to create html file `var'_tmd"
}
markstat using `var'_tmd
capture rm `var'_write.stmd
capture rm `var'_write1.stmd
capture rm `var'_write2.stmd
capture rm `var'_write3.stmd
capture rm `var'_write4.stmd
capture rm `var'_tmd.smcl
if "`keepmd'" != "keepmd" {
capture rm `var'_tmd.stmd
}
************************************* verbose ********************************************
if "`verbose'" == "verbose" {
di ""
di "------------------------ end write_var.ado ----------------------------"
}
******************************************************************************************
end