-
Notifications
You must be signed in to change notification settings - Fork 11
/
cscript.do
1765 lines (1538 loc) · 37.5 KB
/
cscript.do
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
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
* -odkmeta- cscript
* -version- intentionally omitted for -cscript-.
* 1 to complete test 124; 0 not to.
local test124 0
* 1 to complete live-project testing; 0 not to.
local project 0
* 1 to execute profile.do after completion; 0 not to.
local profile 1
/* -------------------------------------------------------------------------- */
/* initialize */
* Check the parameters.
assert inlist(`test124', 0, 1)
assert inlist(`project', 0, 1)
assert inlist(`profile', 0, 1)
* Check that -renvars- is installed.
which renvars
c odkmeta
cd src/cscript
cap log close odkmeta
log using odkmeta, name(odkmeta) s replace
di c(username)
di "`:environment computername'"
clear all
if c(maxvar) < 5450 ///
set maxvar 5450
set varabbrev off
set type float
vers 11.2: set seed 889305539
set more off
adopath ++ `"`c(pwd)'/../build"'
adopath ++ `"`c(pwd)'/ado"'
write_odkmeta_ado
timer clear 1
timer on 1
* Preserve select globals.
loc FASTCDPATH : copy glo FASTCDPATH
cscript odkmeta adofile odkmeta
* Check that Mata issues no warning messages about the source code.
if c(stata_version) >= 13 {
matawarn odkmeta.ado
assert !r(warn)
cscript
}
* Restore globals.
glo FASTCDPATH : copy loc FASTCDPATH
* Define -shortnames-, a program to change an -odkmeta- do-file so that it
* attempts to name variables using their short names.
* Syntax: shortnames filename
run shortnames
* Define -get_warnings-, a program to return the warning messages of an
* -odkmeta- do-file.
* Syntax: -get_warnings do_file_name-
run get_warnings
cd tests
* Erase do-files and .dta files not in an "expected" directory.
loc dirs : dir . dir *
foreach dir of loc dirs {
loc dtas : dir "`dir'" file "*.dta"
foreach dta of loc dtas {
erase "`dir'/`dta'"
}
loc dofiles : dir "`dir'" file "*.do"
foreach do of loc dofiles {
erase "`dir'/`do'"
}
}
/* -------------------------------------------------------------------------- */
/* example test */
* Test 1
cd 1
odkmeta using "ODK to Stata.do", ///
csv(Audio audit test.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
/* -------------------------------------------------------------------------- */
/* basic */
* Test 2
cd 2
conf new f "ODK to Stata.do"
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest2.csv) survey(survey.csv) choices(choices.csv)
get_warnings "ODK to Stata"
assert `"`r(badname_repeats)'"' == ""
assert "`r(badname_vars)'" == ""
assert `"`r(datanotform_repeats)'"' == ""
assert "`r(datanotform_vars)'" == ""
assert `"`r(formnotdata_repeats)'"' == ""
assert "`r(formnotdata_vars)'" == ""
compall expected
cd ..
* Test 19
cd 19
forv i = 1/2 {
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest2.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
}
cd ..
* Test 48
cd 48
odkmeta using "ODK to Stata.do", ///
csv(Audio audit test.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
* Test 52
cd 52
#d ;
odkmeta using "ODK to Stata.do",
csv(Audio audit test.csv)
survey(survey.csv, type(A) name(B) label(C) disabled(D))
choices(choices.csv, listname(A) name(B) label(C))
replace
;
#d cr
run "ODK to Stata"
compall expected
cd ..
* Test 54
cd 54
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest2.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
* Test 71
cd 71
cap erase "ODK to Stata.do"
odkmeta using "ODK to Stata", ///
csv(odkmetatest2.csv) survey(survey.csv) choices(choices.csv) replace
conf f "ODK to Stata.do"
run "ODK to Stata"
compall expected
cd ..
* Test 73
cd 73
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest2) survey(survey) choices(choices) replace
run "ODK to Stata"
compall expected
cd ..
* Test 75
cd 75
odkmeta using "ODK to Stata.do", ///
csv("odkmetatest2.csv") survey("survey.csv") choices("choices.csv") replace
run "ODK to Stata"
compall expected
cd ..
* Test 76
cd 76
#d ;
odkmeta using "ODK to Stata.do",
csv("Audio audit test.csv")
survey("survey.csv", type(A) name(B) label(C) disabled(D))
choices("choices.csv", listname(A) name(B) label(C))
replace
;
#d cr
run "ODK to Stata"
compall expected
cd ..
/*
* Test 77
cd 77
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest2.csv) survey(survey.csv, type(t\`ype)) ///
choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
*/
* Test 89
cd 89
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest2.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
* Test 90
cd 90
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest2.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
* Test 96
cd 96
odkmeta using "ODK to Stata.do", ///
csv(Audio audit test.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
* Test 108
cd 108
odkmeta using import, ///
csv("survey data") survey("survey survey") choices("survey choices") replace
run import
compall expected
cd ..
* Test 109
cd 109
odkmeta using import, ///
csv(survey data) survey(survey survey) choices(survey choices) replace
run import
compall expected
cd ..
* Test 157
cd 157
odkmeta using import, csv(data) survey(survey) choices(choices) replace
run import
compall expected
cd ..
* Test 199
cd 199
odkmeta using "ODK to Stata.do", ///
csv(Audio audit test.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
* Test 208
cd 208
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest2.csv) survey(survey.csv) choices(choices.csv)
run "ODK to Stata"
compall expected
cd ..
/* -------------------------------------------------------------------------- */
/* .csv file */
* Test 3
cd 3
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest3.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
* Test 4
cd 4
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest3.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
* Test 5
cd 5
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest5.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
* Test 6
cd 6
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest5.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
* Test 7
cd 7
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest5.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
* Test 8
cd 8
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest8.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
* Test 9
cd 9
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest9.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
* Test 10
cd 10
odkmeta using "ODK to Stata.do", ///
csv("odkmetatest10 data.csv") survey("odk survey.csv") choices("odk choices.csv") replace
run "ODK to Stata"
compall expected
cd ..
* Test 27
cd 27
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest27.csv) survey(survey.csv) choices(choices.csv) replace
get_warnings "ODK to Stata"
assert `"`r(badname_repeats)'"' == `""""'
assert "`r(badname_vars)'" == "v3"
assert `"`r(datanotform_repeats)'"' == ""
assert "`r(datanotform_vars)'" == ""
assert `"`r(formnotdata_repeats)'"' == ""
assert "`r(formnotdata_vars)'" == ""
compall expected
cd ..
* Test 28
cd 28
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest28.csv) survey(survey.csv) choices(choices.csv) replace
get_warnings "ODK to Stata"
assert `"`r(badname_repeats)'"' == `""" "" "" """'
assert "`r(badname_vars)'" == "v3 v6 v9 v12"
assert `"`r(datanotform_repeats)'"' == ""
assert "`r(datanotform_vars)'" == ""
assert `"`r(formnotdata_repeats)'"' == ""
assert "`r(formnotdata_vars)'" == ""
compall expected
cd ..
* Test 29
cd 29
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest29.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
* Test 80
cd 80
odkmeta using "ODK to Stata.do", ///
csv(data.csv) survey(survey.csv) choices(choices.csv) replace
get_warnings "ODK to Stata"
assert `"`r(badname_repeats)'"' == `""" """'
assert "`r(badname_vars)'" == "v2 v3"
assert `"`r(datanotform_repeats)'"' == `""" """'
assert "`r(datanotform_vars)'" == "_uuid _submission_time"
assert `"`r(formnotdata_repeats)'"' == ""
assert "`r(formnotdata_vars)'" == ""
compall expected
cd ..
* Test 84
cd 84
odkmeta using import, ///
csv(odkmetatest84.csv) survey(survey.csv) choices(choices.csv) replace
get_warnings import
assert `"`r(badname_repeats)'"' == `""""'
assert "`r(badname_vars)'" == "v3"
assert `"`r(datanotform_repeats)'"' == ""
assert "`r(datanotform_vars)'" == ""
assert `"`r(formnotdata_repeats)'"' == ""
assert "`r(formnotdata_vars)'" == ""
compall expected
cd ..
* Test 85
cd 85
odkmeta using import, ///
csv(odkmetatest2.csv) survey(survey.csv) choices(choices.csv) replace
tempfile new
filefilter import.do `new', from(fields)
assert !r(occurrences)
get_warnings import
assert `"`r(badname_repeats)'"' == ""
assert "`r(badname_vars)'" == ""
assert `"`r(datanotform_repeats)'"' == ""
assert "`r(datanotform_vars)'" == ""
assert `"`r(formnotdata_repeats)'"' == ""
assert "`r(formnotdata_vars)'" == ""
compall expected
cd ..
* Test 86
cd 86
odkmeta using import, ///
csv(odkmetatest86.csv) survey(survey.csv) choices(choices.csv) replace
get_warnings import
assert `"`r(badname_repeats)'"' == `""" "" "" "" "" "" """'
assert "`r(badname_vars)'" == "v2 v3 v4 v5 v6 v7 v8"
assert `"`r(datanotform_repeats)'"' == ""
assert "`r(datanotform_vars)'" == ""
assert `"`r(formnotdata_repeats)'"' == ""
assert "`r(formnotdata_vars)'" == ""
compall expected
cd ..
* Test 91
cd 91
odkmeta using import, ///
csv(odkmetatest91.csv) survey(survey.csv) choices(choices.csv) replace
run import
compall expected
cd ..
* Test 103
cd 103
odkmeta using import, csv(data) survey(survey) choices(choices) replace
tempfile temp
filefilter import.do `temp', ///
from("* Rename any variable names that are difficult for -split-.") ///
to("renvars thirtytwocharactersagainonfruits \BS fruits32")
copy `temp' import.do, replace
get_warnings import
assert `"`r(badname_repeats)'"' == `""" "" "" """'
assert "`r(badname_vars)'" == "v7 v9 v13 v17"
assert `"`r(datanotform_repeats)'"' == ""
assert "`r(datanotform_vars)'" == ""
assert `"`r(formnotdata_repeats)'"' == ""
assert "`r(formnotdata_vars)'" == ""
compall expected
cd ..
* Test 104
cd 104
odkmeta using import, csv(odkmetatest104) ///
survey(survey) choices(choices) replace
get_warnings import
assert `"`r(badname_repeats)'"' == `""" "" """'
assert "`r(badname_vars)'" == "v3 v11 v12"
assert `"`r(datanotform_repeats)'"' == ""
assert "`r(datanotform_vars)'" == ""
assert `"`r(formnotdata_repeats)'"' == ""
assert "`r(formnotdata_vars)'" == ""
compall expected
cd ..
* Test 148
cd 148
odkmeta using import, ///
csv(Audio.audit.test.csv) survey(survey) choices(choices) replace
run import
compall expected
cd ..
/* -------------------------------------------------------------------------- */
/* field types */
* Test 50
cd 50
odkmeta using import, ///
csv(odkmetatest50.csv) survey(survey.csv) choices(choices.csv) replace
run import
compall expected
cd ..
* Test 102
cd 102
odkmeta using import, ///
csv(odkmetatest102.csv) survey(survey.csv) choices(choices.csv) replace
run import
compall expected
cd ..
* Test 141
cd 141
odkmeta using "import.do", ///
csv("data.csv") ///
survey("survey.csv") choices("choices.csv") replace
tempfile temp
filefilter import.do `temp', ///
from("local datetimemask MDYhms") to("local datetimemask DMYhms")
assert r(occurrences) == 1
copy `temp' import.do, replace
run import
compall expected
cd ..
* Test 145
cd 145
odkmeta using "import.do", csv(data) survey(survey) choices(choices)
tempfile temp
filefilter import.do `temp', ///
from("local datetimemask MDYhms") to("local datetimemask DMYhms") replace
assert r(occurrences) == 1
copy `temp' import.do, replace
filefilter import.do `temp', ///
from("local timemask hms") to("local timemask hm") replace
assert r(occurrences) == 1
copy `temp' import.do, replace
filefilter import.do `temp', ///
from("local datemask MDY") to("local datemask DMY") replace
assert r(occurrences) == 1
copy `temp' import.do, replace
run import
compall expected
cd ..
/* -------------------------------------------------------------------------- */
/* attributes */
* Test 11
cd 11
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest2.csv) choices(choices.csv) replace ///
survey(survey.csv, type(Type))
run "ODK to Stata"
compall expected
cd ..
* Test 24
cd 24
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest24.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
* Test 25
cd 25
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest25.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
* Test 101
cd 101
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest101.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
/* -------------------------------------------------------------------------- */
/* lists */
* Test 12
cd 12
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest12.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
* Test 20
cd 20
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest20.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
* Test 21
cd 21
odkmeta using import, ///
csv(odkmetatest21.csv) survey(survey.csv) choices(choices.csv) replace
run import
compall expected
cd ..
* Test 22
cd 22
odkmeta using import, ///
csv(odkmetatest22.csv) survey(survey.csv) choices(choices.csv) replace
run import
compall expected
cd ..
* Test 23
cd 23
odkmeta using import, ///
csv(odkmetatest23.csv) survey(survey.csv) choices(choices.csv) replace
run import
compall expected
cd ..
* Test 36
cd 36
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest36.csv) survey(survey.csv) choices(choices.csv) replace
get_warnings "ODK to Stata"
assert `"`r(badname_repeats)'"' == ""
assert "`r(badname_vars)'" == ""
assert `"`r(datanotform_repeats)'"' == `""" """'
assert "`r(datanotform_vars)'" == "_uuid _submission_time"
assert `"`r(formnotdata_repeats)'"' == ""
assert "`r(formnotdata_vars)'" == ""
compall expected
cd ..
* Test 41
cd 41
odkmeta using "import online.do", ///
csv(odkmetatest36.csv) survey(survey.csv) choices(choices.csv) replace ///
oneline
run "import online"
compall expected
tempfile new
filefilter "import online.do" `new', from(;)
assert r(occurrences) == 4
filefilter "import online.do" `new', from(#delimit) replace
assert r(occurrences) == 4
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest36.csv) survey(survey.csv) choices(choices.csv) replace
filefilter "ODK to Stata.do" `new', from(;) replace
assert r(occurrences) > 4
filefilter "ODK to Stata.do" `new', from(#delimit) replace
assert r(occurrences) > 4
cd ..
* Test 47
cd 47
odkmeta using import, ///
csv(odkmetatest47.csv) survey(survey.csv) choices(choices.csv) replace
run import
compall expected
cd ..
* Test 56
cd 56
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest56.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
* Test 57
cd 57
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest56.csv) survey(survey.csv) choices(choices.csv) replace ///
other(max)
run "ODK to Stata"
compall expected
cd ..
* Test 58
cd 58
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest56.csv) survey(survey.csv) choices(choices.csv) replace ///
other(min)
run "ODK to Stata"
compall expected
cd ..
* Test 59
cd 59
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest56.csv) survey(survey.csv) choices(choices.csv) replace ///
other(99)
run "ODK to Stata"
compall expected
cd ..
* Test 60
cd 60
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest56.csv) survey(survey.csv) choices(choices.csv) replace ///
other(.o)
run "ODK to Stata"
compall expected
cd ..
* Test 72
cd 72
odkmeta using import, ///
csv(odkmetatest72.csv) survey(survey.csv) choices(choices.csv) replace
run import
compall expected
cd ..
* Test 83
cd 83
odkmeta using "ODK to Stata.do", ///
csv(odkmetatest36.csv) survey(survey.csv) choices(choices.csv) replace
run "ODK to Stata"
compall expected
cd ..
* Test 87
cd 87
odkmeta using import, ///
csv(odkmetatest87.csv) survey(survey.csv) choices(choices.csv) replace
run import
compall expected
cd ..
* Test 92
cd 92
odkmeta using import, csv(data) survey(survey) choices(choices) replace
run import
compall expected
cd ..
* Test 93
cd 93
odkmeta using import, csv(data) survey(survey) choices(choices) replace
run import
compall expected
cd ..
* Test 94
cd 94
odkmeta using import, csv(data) survey(survey) choices(choices) replace
run import
compall expected
cd ..
* Test 106
cd 106
odkmeta using import, csv(data) survey(survey) choices(choices) replace
run import
compall expected
cd ..
* Test 107
cd 107
odkmeta using import, csv(data) survey(survey) choices(choices) replace
run import
compall expected
cd ..
* Test 137
cd 137
odkmeta using import, csv(data) survey(survey) choices(choices) replace
run import
compall expected
cd ..
* Test 138
cd 138
odkmeta using import, ///
csv(odkmetatest36.csv) survey(survey.csv) choices(choices.csv) replace
run import
compall expected
cd ..
* Test 139
cd 139
odkmeta using import, ///
csv(Audio audit test.csv) survey(survey.csv) choices(choices.csv) replace
run import
compall expected
cd ..
* Test 140
cd 140
odkmeta using import, ///
csv(Audio audit test.csv) survey(survey.csv) choices(choices.csv) replace
run import
compall expected
cd ..
* Test 142
cd 142
odkmeta using "import.do", ///
csv("data.csv") ///
survey("survey.csv") choices("choices.csv") replace
run import
compall expected
cd ..
* Test 143
cd 143
odkmeta using "import.do", ///
csv("data.csv") ///
survey("survey.csv") choices("choices.csv") replace
run import
compall expected
cd ..
* Test 144
cd 144
odkmeta using "import.do", ///
csv("data.csv") ///
survey("survey.csv") choices("choices.csv") replace
run import
compall expected
cd ..
* Test 197
cd 197
odkmeta using "import.do", ///
csv("data.csv") ///
survey("survey.csv") choices("choices.csv") replace
run import
compall expected
cd ..
/* -------------------------------------------------------------------------- */
/* -specialexp()- */
* Test 191
cd 191
odkmeta using import, ///
csv(odkmetatest21.csv) survey(survey.csv) choices(choices.csv) replace
run import
compall expected
cd ..
* Test 192
cd 192
odkmeta using import, ///
csv(odkmetatest21.csv) survey(survey.csv) choices(choices.csv) replace
run import
compall expected
cd ..
* Test 193
cd 193
odkmeta using import, ///
csv(odkmetatest21.csv) survey(survey.csv) choices(choices.csv) replace
run import
compall expected
cd ..
* Test 194
cd 194
odkmeta using import, ///
csv(odkmetatest21.csv) survey(survey.csv) choices(choices.csv) replace
run import
compall expected
cd ..
* Test 195
cd 195
odkmeta using import, ///
csv(odkmetatest21.csv) survey(survey.csv) choices(choices.csv) replace
run import
compall expected
cd ..
* Test 196
cd 196
odkmeta using import, ///
csv(odkmetatest12.csv) survey(survey.csv) choices(choices.csv) replace
run import
compall expected
cd ..
/* -------------------------------------------------------------------------- */
/* groups and repeats */
* Test 98
cd 98
odkmeta using import, ///
csv(odkmetatest84.csv) survey(survey.csv) choices(choices.csv) replace
get_warnings import
assert `"`r(badname_repeats)'"' == `""""'
assert "`r(badname_vars)'" == "v3"
assert `"`r(datanotform_repeats)'"' == ""
assert "`r(datanotform_vars)'" == ""
assert `"`r(formnotdata_repeats)'"' == ""
assert "`r(formnotdata_vars)'" == ""
compall expected
cd ..
* Test 110
cd 110
odkmeta using import, csv(data) survey(survey) choices(choices) replace
run import
compall expected
cd ..
* Test 111
cd 111
odkmeta using import, ///
csv(odkmetatest111) survey(survey) choices(choices) replace
run import
compall expected
cd ..
* Test 112
cd 112
odkmeta using import, ///
csv(odkmetatest112) survey(survey) choices(choices) replace
run import
compall expected
cd ..
* Test 113
cd 113
odkmeta using import, ///
csv(odkmetatest113) survey(survey) choices(choices) replace
run import
compall expected
cd ..
* Test 114
cd 114
odkmeta using import, ///
csv(odkmetatest114) survey(survey) choices(choices) replace
run import
compall expected
cd ..
* Test 115
cd 115
odkmeta using import, ///
csv(odkmetatest115) survey(survey) choices(choices) replace
run import
compall expected
cd ..
* Test 116
cd 116
odkmeta using import, csv(data) survey(survey) choices(choices) replace
run import
* Check the dataset.
compall expected
* Check the do-file.
infix str line 1-244 using import.do, clear
gen ln = _n
su ln if line == "* begin group G1"
assert r(N) == 1
assert line[r(min) + 1] == "* begin group G2"
su ln if line == "* end group G2"
assert r(N) == 1
assert line[r(min) + 1] == "* end group G1"
cd ..
* Test 117
cd 117
odkmeta using import, ///
csv(odkmetatest117) survey(survey) choices(choices) replace
run import
compall expected
cd ..
* Test 124
cd 124
* Do-file only
if `test124' {
forv i = 1/25 {
drop _all
set obs `=ceil(10 * runiform())'
gen order = _n
gen type = "text"
gen name = "field" + strofreal(order)
foreach collec in repeat group {
forv j = 1/`=floor(301 * runiform())' {
preserve
drop _all
* "+ 2" for "begin group/repeat" and "end group/repeat"
set obs `=ceil(3 * runiform()) + 2'
gen collecorder = _n
gen type = ""
gen name = ""
replace type = "begin `collec'" in 1
replace name = "`collec'`j'" in 1
replace type = "end `collec'" in L
replace type = "integer" if mi(type)
replace name = "`collec'`j'_field" + strofreal(_n) if mi(name)