-
Notifications
You must be signed in to change notification settings - Fork 21
/
Macros.sas
2498 lines (2258 loc) · 106 KB
/
Macros.sas
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
/**********************************************************************************************/
/* CREATED BY: Ryan Ball (UNC-Chapel Hill) */
/* MODIFIED BY: Scott Dyreng (UNC-Chapel Hill) */
/* DATE CREATED: November 29, 2005 */
/* LAST MODIFIED: November 29, 2005 */
/* MACRO NAME: Lags */
/* ARGUMENTS: 1) DATA: input dataset containing variables that will be lagged */
/* 2) FIRMID: firm-specific identification variable */
/* 3) TIMEID: date variable (e.g fyenddt, fqenddt) */
/* 4) VARS: variable(s) that will be lagged..macro will automatically add a */
/* '_lead#' or '_lag#' suffix to all lead/lag variables */
/* 5) LAG_TYPE: = 1 if monthly data is used */
/* = 3 if quarterly data is used */
/* = 12 if yearly data is used (default) */
/* 5) NUM_LAGS: number of lags taken...positive values represent lags of each*/
/* variable while negative value represent lead values */
/* 6) OUT: = output dataset with orinal plus lagged variables */
/* DESCRIPTION: This macro takes the input variables and computes lagged variables based */
/* on other specifications (e.g. FIRMID, TIMEID, LAG_TYPE) */
/**********************************************************************************************/
%macro lags (data = _LAST_,
firmid = ,
timeid = ,
vars = ,
lag_type = 12,
num_lags = 1,
out = );
/*set LAG_TYPE = 12 (default) if something other than 1 or 3 is specified*/
%if &out = %then %let out = &data;
%if &lag_type ne 1 & &lag_type ne 3 & &lag_type ne 12 %then %let lag_type = "OOPS!";
%if &num_lags < 0 %then %do;
%let temp_suffix = %eval(-1 * &num_lags);
%let prefix = lead&temp_suffix;
%end;
%else %if &num_lags >= 0 %then %do;
%let prefix = lag&num_lags;
%end;
/*create a macro variable with the names of the lagged variables*/
%let lagged_names =;
%let variable_index = 1;
%do %until (%scan(&vars,&variable_index)= );
%let token = %scan(&vars,&variable_index);
%let lagged_names = &lagged_names &token._&prefix;
%let variable_index = %eval(&variable_index + 1);
%end;
/*sort data in ascending order*/
proc sort data = &data;
by &firmid &timeid;
run;
/*create duplicate dataset but change the date to correspond to lagged dates*/
data temp;
set &data;
array vars(*) &vars;
array nvars(*) &lagged_names;
&timeid = intnx('month', &timeid, 1 + &num_lags * &lag_type) - 1;
do i = 1 to dim(nvars);
nvars(i) = vars(i); /*method of renaming variables*/
end;
keep &timeid &firmid &lagged_names;
run;
proc sql;
create table &out
as select a.*, b.*
from &data as a left join temp as b
on a.&firmid = b.&firmid & month(a.&timeid) = month(b.&timeid) &
year(a.&timeid) = year(b.&timeid);
quit;run;
proc sort data = &out;
by &firmid &timeid;
quit;run;
proc datasets library=work nolist;
delete temp;
quit;
run;
%mend;
**********************************************************************************************/
/* ORIGINAL AUTHOR: Steve Stubben (Stanford University) */
/* MODIFIED BY: Ryan Ball (UNC-Chapel Hill), Scott Dyreng (UNC-Chapel Hill) */
/* DATE CREATED: August 3, 2005 */
/* LAST MODIFIED: December 7, 2005 */
/* MACRO NAME: WT */
/* ARGUMENTS: 1) data: input dataset containing variables that will be win/trunc. */
/* 2) out: output dataset (leave blank to overwrite data) */
/* 3) BYVAR: variable(s) used to form groups (leave blank for total sample) */
/* 4) VARS: variable(s) that will be winsorized/truncated */
/* 5) TYPE: = W to winsorize and = T (or anything else) to truncate */
/* 6) PCTL = percentile points (in ascending order) to truncate/winsorize */
/* values. Default is 1st and 99th percentiles. */
/* DESCRIPTION: This macro is capable of both truncating and winsorizing one or multiple */
/* variables. Truncated values are replaced with a missing observation */
/* rather than deleting the observation. This gives the user more control */
/* over the resulting dataset. */
/* EXAMPLE(S): 1) %WT(data = mydata, out = mydata2, byvar = year, */
/* vars = assets earnings, type = W, pctl = 0 98) */
/* ==> Winsorizes by year at 98% and puts resulting dataset into mydata2 */
/**********************************************************************************************/;
%macro WT(data=_last_, out=, byvar=none, vars=, type = W, pctl = 1 99, drop= N);
%if &out = %then %let out = &data;
%let varLow=;
%let varHigh=;
%let xn=1;
%do %until (%scan(&vars,&xn)= );
%let token = %scan(&vars,&xn);
%let varLow = &varLow &token.Low;
%let varHigh = &varHigh &token.High;
%let xn = %EVAL(&xn + 1);
%end;
%let xn = %eval(&xn-1);
data xtemp;
set &data;
%let dropvar = ;
%if &byvar = none %then %do;
data xtemp;
set xtemp;
xbyvar = 1;
%let byvar = xbyvar;
%let dropvar = xbyvar;
%end;
proc sort data = xtemp;
by &byvar;
/*compute percentage cutoff values*/
proc univariate data = xtemp noprint;
by &byvar;
var &vars;
output out = xtemp_pctl PCTLPTS = &pctl PCTLPRE = &vars PCTLNAME = Low High;
data &out;
merge xtemp xtemp_pctl; /*merge percentage cutoff values into main dataset*/
by &byvar;
array trimvars{&xn} &vars;
array trimvarl{&xn} &varLow;
array trimvarh{&xn} &varHigh;
do xi = 1 to dim(trimvars);
/*winsorize variables*/
%if &type = W %then %do;
if trimvars{xi} ne . then do;
if (trimvars{xi} < trimvarl{xi}) then trimvars{xi} = trimvarl{xi};
if (trimvars{xi} > trimvarh{xi}) then trimvars{xi} = trimvarh{xi};
end;
%end;
/*truncate variables*/
%else %do;
if trimvars{xi} ne . then do;
if (trimvars{xi} < trimvarl{xi}) then trimvars{xi} = .T;
if (trimvars{xi} > trimvarh{xi}) then trimvars{xi} = .T;
end;
%end;
%if &drop = Y %then %do;
if trimvars{xi} = .T then delete;
%end;
end;
drop &varLow &varHigh &dropvar xi;
/*delete temporary datasets created during macro execution*/
proc datasets library=work nolist;
delete xtemp xtemp_pctl; quit; run;
%mend;
**********************************************************************************************/
/* ORIGINAL AUTHOR: Steve Stubben (Stanford University) */
/* MODIFIED BY: Ryan Ball (UNC-Chapel Hill), Scott Dyreng (UNC-Chapel Hill) */
/* DATE CREATED: August 3, 2005 */
/* LAST MODIFIED: December 7, 2005 */
/* MACRO NAME: WTSTD */
/* ARGUMENTS: 1) data: input dataset containing variables that will be win/trunc. */
/* 2) out: output dataset (leave blank to overwrite data) */
/* 3) BYVAR: variable(s) used to form groups (leave blank for total sample) */
/* 4) VARS: variable(s) that will be winsorized/truncated */
/* 5) TYPE: = W to winsorize and = T (or anything else) to truncate */
/* 6) deviations = number of standard deviations away from the mean to winsorize/truncate*/
/* DESCRIPTION: This macro is capable of both truncating and winsorizing one or multiple */
/* variables. Truncated values are replaced with a missing observation */
/* rather than deleting the observation. This gives the user more control */
/* over the resulting dataset. */
/* EXAMPLE(S): 1) %WT(data = mydata, out = mydata2, byvar = year, */
/* vars = assets earnings, type = W, pctl = 0 98) */
/* ==> Winsorizes by year at 98% and puts resulting dataset into mydata2 */
/**********************************************************************************************/;
%macro WTSTD(data=_last_, out=, byvar=none, vars=, type = W, deviations = 3, drop= N);
%if &out = %then %let out = &data;
%let var_stddev=;
%let var_mean=;
%let xn=1;
%do %until (%scan(&vars,&xn)= );
%let token = %scan(&vars,&xn);
%let var_stddev = &var_stddev &token._stddev;
%let var_mean = &var_mean &token._mean;
%let xn = %EVAL(&xn + 1);
%end;
%let xn = %eval(&xn-1);
data xtemp;
set &data;
%let dropvar = ;
%if &byvar = none %then %do;
data xtemp;
set xtemp;
xbyvar = 1;
%let byvar = xbyvar;
%let dropvar = xbyvar;
%end;
proc sort data = xtemp;
by &byvar;
/*compute percentage cutoff values*/
proc means data = xtemp noprint;
by &byvar;
var &vars;
output out = xtemp_pctl(drop=_type_ _freq_) std= mean=/autoname;
run;
data &out;
merge xtemp xtemp_pctl; /*merge percentage cutoff values into main dataset*/
by &byvar;
array trimvars{&xn} &vars;
array trimvar_std{&xn} &var_stddev;
array trimvar_mean{&xn} &var_mean;
do xi = 1 to dim(trimvars);
/*winsorize variables*/
%if &type = W %then %do;
if trimvars{xi} ne . then do;
if (trimvars{xi} < trimvar_mean{xi}-(trimvar_std{xi}*&deviations))
then trimvars{xi} = trimvar_mean{xi}-(trimvar_std{xi}*&deviations));
if (trimvars{xi} > trimvar_mean{xi}+(trimvar_std{xi}*&deviations))
then trimvars{xi} = trimvar_mean{xi}+(trimvar_std{xi}*&deviations));
end;
%end;
/*truncate variables*/
%else %do;
if trimvars{xi} ne . then do;
if (trimvars{xi} < trimvar_mean{xi}-(trimvar_std{xi}*&deviations))
then trimvars{xi} = .T;
if (trimvars{xi} > trimvar_mean{xi}+(trimvar_std{xi}*&deviations))
then trimvars{xi} = .T;
end;
%end;
%if &drop = Y %then %do;
if trimvars{xi} = .T then delete;
%end;
end;
drop &var_stddev &var_mean &dropvar xi;
/*delete temporary datasets created during macro execution*/
proc datasets library=work nolist;
delete xtemp xtemp_pctl; quit; run;
%mend;
/**********************************************************************************************/
/* CREATED BY: Scott Dyreng (UNC-Chapel Hill) */
/* MODIFIED BY: Scott Dyreng (UNC-Chapel Hill) */
/* DATE CREATED: December 16, 2005 */
/* LAST MODIFIED: December 16, 2005 */
/* MACRO NAME: LagsYA */
/* ARGUMENTS: 1) DATA: input dataset containing variables that will be lagged */
/* 2) FIRMID: firm-specific identification variable */
/* 4) VARS: variable(s) that will be lagged..macro will automatically add a */
/* '_lead#' or '_lag#' suffix to all lead/lag variables */
/*
/* 5) NUM_LAGS: number of lags taken...positive values represent lags of each*/
/* variable while negative value represent lead values */
/* 6) OUT: = output dataset with orinal plus lagged variables */
/* DESCRIPTION: This macro is the same as the lags macro, except it only works
for compustat where the time identifier is yeara. */
/**********************************************************************************************/
%macro lagsYA (data = _LAST_,
firmid = ,
vars = ,
num_lags = 1,
out =,
yearid=yeara);
/*set LAG_TYPE = 12 (default) if something other than 1 or 3 is specified*/
%if &out = %then %let out = &data;
%if &num_lags < 0 %then %do;
%let temp_suffix = %eval(-1 * &num_lags);
%let prefix = lead&temp_suffix;
%end;
%else %if &num_lags >= 0 %then %do;
%let prefix = lag&num_lags;
%end;
/*create a macro variable with the names of the lagged variables*/
%let lagged_names =;
%let variable_index = 1;
%do %until (%scan(&vars,&variable_index)= );
%let token = %scan(&vars,&variable_index);
%let lagged_names = &lagged_names &token._&prefix;
%let variable_index = %eval(&variable_index + 1);
%end;
/*sort data in ascending order*/
proc sort data = &data;
by &firmid &yearid;
run;
/*create duplicate dataset but change the date to correspond to lagged dates*/
data temp;
set &data;
array vars(*) &vars;
array nvars(*) &lagged_names;
&yearid = &yearid + &num_lags;
do i = 1 to dim(nvars);
nvars(i) = vars(i); /*method of renaming variables*/
end;
keep &yearid &firmid &lagged_names;
run;
proc sql;
create table &out
as select a.*, b.*
from &data as a left join temp as b
on a.&firmid = b.&firmid & a.&yearid = b.&yearid;
quit;run;
proc sort data = &out;
by &firmid &yearid;
quit;run;
proc datasets library=work nolist;
delete temp;
quit;
run;
%mend;
/**********************************************************************************************/
/* CREATED BY: Scott Dyreng (UNC-Chapel Hill) */
/* MODIFIED BY: Scott Dyreng (UNC-Chapel Hill) */
/* DATE CREATED: December 16, 2005 */
/* LAST MODIFIED: December 16, 2005 */
/* MACRO NAME: FMB */
/* ARGUMENTS: 1) */
/* DESCRIPTION: This macro computes Fama McBeth Regression Estimates; */
/**********************************************************************************************/
%macro FMB(data=_last_, byvars=, depvar=, indvars=, testvar1=0, testvar2=0, testname=diff);
proc sort data=&data;
by &byvars;
run;
proc reg noprint data=&data outest=FMBtemp1;
by &byvars;
model &depvar = &indvars / adjrsq;
run;
quit;
data FMBtemp1;
set FMBtemp1;
&testname = &testvar1 - &testvar2;
run;
data FMBtemp2;
set &data;
array vars1(*) &depvar;
array vars2(*) &indvars;
do i=1 to dim(vars1);
if missing(vars1(i))=1 then delete;
end;
do j=1 to dim(vars2);
if missing(vars2(j))=1 then delete;
end;
run;
proc means data=FMBtemp1 n mean median stderr t probt;
title "Fama McBeth Estimates";
var intercept &indvars &testname;
run;
proc sort data=FMBtemp2;
by &byvars;
run;
proc means data=FMBtemp2 noprint;
by &byvars;
var &depvar;
output out=FMBtemp2(drop=_type_ _freq_) n=nobs;
run;
proc print data=FMBtemp2;
title "Number of Observations per Cross Section";
run;
proc print data=FMBtemp1;
title "Cross Sectional Coefficient Estimates by &byvars";
var &byvars intercept &indvars &testname _RSQ_ _ADJRSQ_ _EDF_;
run;
proc datasets lib=work nolist;
delete FMBtemp1 FMBtemp2;
run;
quit;
%mend FMB;
/*****************************************************
Correlations
Prints matrix of correlations, with Pearson above
the diagonal and Spearman below.
ex: %corrps(dset=mydata, vars=assets earnings return);
*****************************************************/
/**********************************************************************************************/
/* CREATED BY: Steve Stubbin (Stanford) */
/* MODIFIED BY: Scott Dyreng (UNC-Chapel Hill) */
/* DATE CREATED: December 16, 2005 */
/* LAST MODIFIED: March 30, 2006 */
/* MACRO NAME: CORRPS */
/* ARGUMENTS: 1) data=dataset name */
/* 2) vars=variable separated by spaces */
/* DESCRIPTION: This macro computes pearson (above) spearman (below) then diagnol with */
/* corresponding p-values in the column next to the correlation; */
/**********************************************************************************************/
%macro corrps(data=,vars=);
%let i=1;
%let j=1;
%do %until (%SCAN(&vars,&i,%STR( ))=);
%let v&j=%SCAN(&vars,&i,%STR( ));
%let j=%EVAL(&j+2);
%let i=%EVAL(&i+1);
%end;
%let i=1;
%let j=2;
%do %until (%SCAN(&vars,&i,%STR( ))=);
%let v&j=P%SCAN(&vars,&i,%STR( ));
%let j=%EVAL(&j+2);
%let i=%EVAL(&i+1);
%end;
%let nvars=%eval(&i-1);
%macro cor_rep(sta,fin);
%do j=&sta %to &fin;
, (xp.&&v&j + xs.&&v&j) as &&v&j
%end;
%mend;
ods output pearsoncorr=xp spearmancorr=xs;
proc corr data=&data pearson spearman;
var &vars;
run;
data xp;
set xp;
array vars {*} &vars;
do i=1 to (_N_ - 1);
vars(i) = 0;
end;
array vars2 {*} P&vars;
do j=1 to (_N_ - 1);
vars2(j) = 0;
end;
drop i j;
run;
data xs;
set xs;
array vars {*} &vars;
do i=_N_ to &nvars;
vars(i) = 0;
end;
array vars2 {*} P&vars;
do j=_N_ to &nvars;
vars2(j) = 0;
end;
drop i j;
run;
proc sql;
create table xps as
select xp.Variable as VARIABLE %cor_rep(1,&nvars*2)
from xp, xs where (xp.Variable = xs.variable);
quit;
proc print data=xps noobs;
title2 'Pearson (above) / Spearman (below) Correlations';
run;
title2;
proc datasets lib=work nolist;
delete xp xs xps;
run;
quit;
%mend;
%macro ff17(data=,newvarname=industry,sic=sic,out=&data);
data &out;
set &data;
&newvarname = 17;
if 100 <= &sic <= 199 then &newvarname = 17 ;
else if 200 <= &sic <= 299 then &newvarname = 1 ;
else if 700 <= &sic <= 799 then &newvarname = 1 ;
else if 900 <= &sic <= 999 then &newvarname = 1 ;
else if 2000 <= &sic <= 2009 then &newvarname = 1 ;
else if 2010 <= &sic <= 2019 then &newvarname = 1 ;
else if 2020 <= &sic <= 2029 then &newvarname = 1 ;
else if 2030 <= &sic <= 2039 then &newvarname = 1 ;
else if 2040 <= &sic <= 2046 then &newvarname = 1 ;
else if 2047 <= &sic <= 2047 then &newvarname = 1 ;
else if 2048 <= &sic <= 2048 then &newvarname = 1 ;
else if 2050 <= &sic <= 2059 then &newvarname = 1 ;
else if 2060 <= &sic <= 2063 then &newvarname = 1 ;
else if 2064 <= &sic <= 2068 then &newvarname = 1 ;
else if 2070 <= &sic <= 2079 then &newvarname = 1 ;
else if 2080 <= &sic <= 2080 then &newvarname = 1 ;
else if 2082 <= &sic <= 2082 then &newvarname = 1 ;
else if 2083 <= &sic <= 2083 then &newvarname = 1 ;
else if 2084 <= &sic <= 2084 then &newvarname = 1 ;
else if 2085 <= &sic <= 2085 then &newvarname = 1 ;
else if 2086 <= &sic <= 2086 then &newvarname = 1 ;
else if 2087 <= &sic <= 2087 then &newvarname = 1 ;
else if 2090 <= &sic <= 2092 then &newvarname = 1 ;
else if 2095 <= &sic <= 2095 then &newvarname = 1 ;
else if 2096 <= &sic <= 2096 then &newvarname = 1 ;
else if 2097 <= &sic <= 2097 then &newvarname = 1 ;
else if 2098 <= &sic <= 2099 then &newvarname = 1 ;
else if 5140 <= &sic <= 5149 then &newvarname = 1 ;
else if 5150 <= &sic <= 5159 then &newvarname = 1 ;
else if 5180 <= &sic <= 5182 then &newvarname = 1 ;
else if 5191 <= &sic <= 5191 then &newvarname = 1 ;
else if 1000 <= &sic <= 1009 then &newvarname = 2 ;
else if 1010 <= &sic <= 1019 then &newvarname = 2 ;
else if 1020 <= &sic <= 1029 then &newvarname = 2 ;
else if 1030 <= &sic <= 1039 then &newvarname = 2 ;
else if 1040 <= &sic <= 1049 then &newvarname = 2 ;
else if 1060 <= &sic <= 1069 then &newvarname = 2 ;
else if 1080 <= &sic <= 1089 then &newvarname = 2 ;
else if 1090 <= &sic <= 1099 then &newvarname = 2 ;
else if 1200 <= &sic <= 1299 then &newvarname = 2 ;
else if 1400 <= &sic <= 1499 then &newvarname = 2 ;
else if 5050 <= &sic <= 5052 then &newvarname = 2 ;
else if 1300 <= &sic <= 1300 then &newvarname = 3 ;
else if 1310 <= &sic <= 1319 then &newvarname = 3 ;
else if 1320 <= &sic <= 1329 then &newvarname = 3 ;
else if 1380 <= &sic <= 1380 then &newvarname = 3 ;
else if 1381 <= &sic <= 1381 then &newvarname = 3 ;
else if 1382 <= &sic <= 1382 then &newvarname = 3 ;
else if 1389 <= &sic <= 1389 then &newvarname = 3 ;
else if 2900 <= &sic <= 2912 then &newvarname = 3 ;
else if 5170 <= &sic <= 5172 then &newvarname = 3 ;
else if 2200 <= &sic <= 2269 then &newvarname = 4 ;
else if 2270 <= &sic <= 2279 then &newvarname = 4 ;
else if 2280 <= &sic <= 2284 then &newvarname = 4 ;
else if 2290 <= &sic <= 2295 then &newvarname = 4 ;
else if 2296 <= &sic <= 2296 then &newvarname = 4 ;
else if 2297 <= &sic <= 2297 then &newvarname = 4 ;
else if 2298 <= &sic <= 2298 then &newvarname = 4 ;
else if 2299 <= &sic <= 2299 then &newvarname = 4 ;
else if 2300 <= &sic <= 2390 then &newvarname = 4 ;
else if 2391 <= &sic <= 2392 then &newvarname = 4 ;
else if 2393 <= &sic <= 2395 then &newvarname = 4 ;
else if 2396 <= &sic <= 2396 then &newvarname = 4 ;
else if 2397 <= &sic <= 2399 then &newvarname = 4 ;
else if 3020 <= &sic <= 3021 then &newvarname = 4 ;
else if 3100 <= &sic <= 3111 then &newvarname = 4 ;
else if 3130 <= &sic <= 3131 then &newvarname = 4 ;
else if 3140 <= &sic <= 3149 then &newvarname = 4 ;
else if 3150 <= &sic <= 3151 then &newvarname = 4 ;
else if 3963 <= &sic <= 3965 then &newvarname = 4 ;
else if 5130 <= &sic <= 5139 then &newvarname = 4 ;
else if 2510 <= &sic <= 2519 then &newvarname = 5 ;
else if 2590 <= &sic <= 2599 then &newvarname = 5 ;
else if 3060 <= &sic <= 3069 then &newvarname = 5 ;
else if 3070 <= &sic <= 3079 then &newvarname = 5 ;
else if 3080 <= &sic <= 3089 then &newvarname = 5 ;
else if 3090 <= &sic <= 3099 then &newvarname = 5 ;
else if 3630 <= &sic <= 3639 then &newvarname = 5 ;
else if 3650 <= &sic <= 3651 then &newvarname = 5 ;
else if 3652 <= &sic <= 3652 then &newvarname = 5 ;
else if 3860 <= &sic <= 3861 then &newvarname = 5 ;
else if 3870 <= &sic <= 3873 then &newvarname = 5 ;
else if 3910 <= &sic <= 3911 then &newvarname = 5 ;
else if 3914 <= &sic <= 3914 then &newvarname = 5 ;
else if 3915 <= &sic <= 3915 then &newvarname = 5 ;
else if 3930 <= &sic <= 3931 then &newvarname = 5 ;
else if 3940 <= &sic <= 3949 then &newvarname = 5 ;
else if 3960 <= &sic <= 3962 then &newvarname = 5 ;
else if 5020 <= &sic <= 5023 then &newvarname = 5 ;
else if 5064 <= &sic <= 5064 then &newvarname = 5 ;
else if 5094 <= &sic <= 5094 then &newvarname = 5 ;
else if 5099 <= &sic <= 5099 then &newvarname = 5 ;
else if 2800 <= &sic <= 2809 then &newvarname = 6 ;
else if 2810 <= &sic <= 2819 then &newvarname = 6 ;
else if 2820 <= &sic <= 2829 then &newvarname = 6 ;
else if 2860 <= &sic <= 2869 then &newvarname = 6 ;
else if 2870 <= &sic <= 2879 then &newvarname = 6 ;
else if 2890 <= &sic <= 2899 then &newvarname = 6 ;
else if 5160 <= &sic <= 5169 then &newvarname = 6 ;
else if 2100 <= &sic <= 2199 then &newvarname = 7 ;
else if 2830 <= &sic <= 2830 then &newvarname = 7 ;
else if 2831 <= &sic <= 2831 then &newvarname = 7 ;
else if 2833 <= &sic <= 2833 then &newvarname = 7 ;
else if 2834 <= &sic <= 2834 then &newvarname = 7 ;
else if 2840 <= &sic <= 2843 then &newvarname = 7 ;
else if 2844 <= &sic <= 2844 then &newvarname = 7 ;
else if 5120 <= &sic <= 5122 then &newvarname = 7 ;
else if 5194 <= &sic <= 5194 then &newvarname = 7 ;
else if 800 <= &sic <= 899 then &newvarname = 8 ;
else if 1500 <= &sic <= 1511 then &newvarname = 8 ;
else if 1520 <= &sic <= 1529 then &newvarname = 8 ;
else if 1530 <= &sic <= 1539 then &newvarname = 8 ;
else if 1540 <= &sic <= 1549 then &newvarname = 8 ;
else if 1600 <= &sic <= 1699 then &newvarname = 8 ;
else if 1700 <= &sic <= 1799 then &newvarname = 8 ;
else if 2400 <= &sic <= 2439 then &newvarname = 8 ;
else if 2440 <= &sic <= 2449 then &newvarname = 8 ;
else if 2450 <= &sic <= 2459 then &newvarname = 8 ;
else if 2490 <= &sic <= 2499 then &newvarname = 8 ;
else if 2850 <= &sic <= 2859 then &newvarname = 8 ;
else if 2950 <= &sic <= 2952 then &newvarname = 8 ;
else if 3200 <= &sic <= 3200 then &newvarname = 8 ;
else if 3210 <= &sic <= 3211 then &newvarname = 8 ;
else if 3240 <= &sic <= 3241 then &newvarname = 8 ;
else if 3250 <= &sic <= 3259 then &newvarname = 8 ;
else if 3261 <= &sic <= 3261 then &newvarname = 8 ;
else if 3264 <= &sic <= 3264 then &newvarname = 8 ;
else if 3270 <= &sic <= 3275 then &newvarname = 8 ;
else if 3280 <= &sic <= 3281 then &newvarname = 8 ;
else if 3290 <= &sic <= 3293 then &newvarname = 8 ;
else if 3420 <= &sic <= 3429 then &newvarname = 8 ;
else if 3430 <= &sic <= 3433 then &newvarname = 8 ;
else if 3440 <= &sic <= 3441 then &newvarname = 8 ;
else if 3442 <= &sic <= 3442 then &newvarname = 8 ;
else if 3446 <= &sic <= 3446 then &newvarname = 8 ;
else if 3448 <= &sic <= 3448 then &newvarname = 8 ;
else if 3449 <= &sic <= 3449 then &newvarname = 8 ;
else if 3450 <= &sic <= 3451 then &newvarname = 8 ;
else if 3452 <= &sic <= 3452 then &newvarname = 8 ;
else if 5030 <= &sic <= 5039 then &newvarname = 8 ;
else if 5070 <= &sic <= 5078 then &newvarname = 8 ;
else if 5198 <= &sic <= 5198 then &newvarname = 8 ;
else if 5210 <= &sic <= 5211 then &newvarname = 8 ;
else if 5230 <= &sic <= 5231 then &newvarname = 8 ;
else if 5250 <= &sic <= 5251 then &newvarname = 8 ;
else if 3300 <= &sic <= 3300 then &newvarname = 9 ;
else if 3310 <= &sic <= 3317 then &newvarname = 9 ;
else if 3320 <= &sic <= 3325 then &newvarname = 9 ;
else if 3330 <= &sic <= 3339 then &newvarname = 9 ;
else if 3340 <= &sic <= 3341 then &newvarname = 9 ;
else if 3350 <= &sic <= 3357 then &newvarname = 9 ;
else if 3360 <= &sic <= 3369 then &newvarname = 9 ;
else if 3390 <= &sic <= 3399 then &newvarname = 9 ;
else if 3410 <= &sic <= 3412 then &newvarname = 10 ;
else if 3443 <= &sic <= 3443 then &newvarname = 10 ;
else if 3444 <= &sic <= 3444 then &newvarname = 10 ;
else if 3460 <= &sic <= 3469 then &newvarname = 10 ;
else if 3470 <= &sic <= 3479 then &newvarname = 10 ;
else if 3480 <= &sic <= 3489 then &newvarname = 10 ;
else if 3490 <= &sic <= 3499 then &newvarname = 10 ;
else if 3510 <= &sic <= 3519 then &newvarname = 11 ;
else if 3520 <= &sic <= 3529 then &newvarname = 11 ;
else if 3530 <= &sic <= 3530 then &newvarname = 11 ;
else if 3531 <= &sic <= 3531 then &newvarname = 11 ;
else if 3532 <= &sic <= 3532 then &newvarname = 11 ;
else if 3533 <= &sic <= 3533 then &newvarname = 11 ;
else if 3534 <= &sic <= 3534 then &newvarname = 11 ;
else if 3535 <= &sic <= 3535 then &newvarname = 11 ;
else if 3536 <= &sic <= 3536 then &newvarname = 11 ;
else if 3540 <= &sic <= 3549 then &newvarname = 11 ;
else if 3550 <= &sic <= 3559 then &newvarname = 11 ;
else if 3560 <= &sic <= 3569 then &newvarname = 11 ;
else if 3570 <= &sic <= 3579 then &newvarname = 11 ;
else if 3580 <= &sic <= 3580 then &newvarname = 11 ;
else if 3581 <= &sic <= 3581 then &newvarname = 11 ;
else if 3582 <= &sic <= 3582 then &newvarname = 11 ;
else if 3585 <= &sic <= 3585 then &newvarname = 11 ;
else if 3586 <= &sic <= 3586 then &newvarname = 11 ;
else if 3589 <= &sic <= 3589 then &newvarname = 11 ;
else if 3590 <= &sic <= 3599 then &newvarname = 11 ;
else if 3600 <= &sic <= 3600 then &newvarname = 11 ;
else if 3610 <= &sic <= 3613 then &newvarname = 11 ;
else if 3620 <= &sic <= 3621 then &newvarname = 11 ;
else if 3622 <= &sic <= 3622 then &newvarname = 11 ;
else if 3623 <= &sic <= 3629 then &newvarname = 11 ;
else if 3670 <= &sic <= 3679 then &newvarname = 11 ;
else if 3680 <= &sic <= 3680 then &newvarname = 11 ;
else if 3681 <= &sic <= 3681 then &newvarname = 11 ;
else if 3682 <= &sic <= 3682 then &newvarname = 11 ;
else if 3683 <= &sic <= 3683 then &newvarname = 11 ;
else if 3684 <= &sic <= 3684 then &newvarname = 11 ;
else if 3685 <= &sic <= 3685 then &newvarname = 11 ;
else if 3686 <= &sic <= 3686 then &newvarname = 11 ;
else if 3687 <= &sic <= 3687 then &newvarname = 11 ;
else if 3688 <= &sic <= 3688 then &newvarname = 11 ;
else if 3689 <= &sic <= 3689 then &newvarname = 11 ;
else if 3690 <= &sic <= 3690 then &newvarname = 11 ;
else if 3691 <= &sic <= 3692 then &newvarname = 11 ;
else if 3693 <= &sic <= 3693 then &newvarname = 11 ;
else if 3694 <= &sic <= 3694 then &newvarname = 11 ;
else if 3695 <= &sic <= 3695 then &newvarname = 11 ;
else if 3699 <= &sic <= 3699 then &newvarname = 11 ;
else if 3810 <= &sic <= 3810 then &newvarname = 11 ;
else if 3811 <= &sic <= 3811 then &newvarname = 11 ;
else if 3812 <= &sic <= 3812 then &newvarname = 11 ;
else if 3820 <= &sic <= 3820 then &newvarname = 11 ;
else if 3821 <= &sic <= 3821 then &newvarname = 11 ;
else if 3822 <= &sic <= 3822 then &newvarname = 11 ;
else if 3823 <= &sic <= 3823 then &newvarname = 11 ;
else if 3824 <= &sic <= 3824 then &newvarname = 11 ;
else if 3825 <= &sic <= 3825 then &newvarname = 11 ;
else if 3826 <= &sic <= 3826 then &newvarname = 11 ;
else if 3827 <= &sic <= 3827 then &newvarname = 11 ;
else if 3829 <= &sic <= 3829 then &newvarname = 11 ;
else if 3830 <= &sic <= 3839 then &newvarname = 11 ;
else if 3950 <= &sic <= 3955 then &newvarname = 11 ;
else if 5060 <= &sic <= 5060 then &newvarname = 11 ;
else if 5063 <= &sic <= 5063 then &newvarname = 11 ;
else if 5065 <= &sic <= 5065 then &newvarname = 11 ;
else if 5080 <= &sic <= 5080 then &newvarname = 11 ;
else if 5081 <= &sic <= 5081 then &newvarname = 11 ;
else if 3710 <= &sic <= 3710 then &newvarname = 12 ;
else if 3711 <= &sic <= 3711 then &newvarname = 12 ;
else if 3714 <= &sic <= 3714 then &newvarname = 12 ;
else if 3716 <= &sic <= 3716 then &newvarname = 12 ;
else if 3750 <= &sic <= 3751 then &newvarname = 12 ;
else if 3792 <= &sic <= 3792 then &newvarname = 12 ;
else if 5010 <= &sic <= 5015 then &newvarname = 12 ;
else if 5510 <= &sic <= 5521 then &newvarname = 12 ;
else if 5530 <= &sic <= 5531 then &newvarname = 12 ;
else if 5560 <= &sic <= 5561 then &newvarname = 12 ;
else if 5570 <= &sic <= 5571 then &newvarname = 12 ;
else if 5590 <= &sic <= 5599 then &newvarname = 12 ;
else if 3713 <= &sic <= 3713 then &newvarname = 13 ;
else if 3715 <= &sic <= 3715 then &newvarname = 13 ;
else if 3720 <= &sic <= 3720 then &newvarname = 13 ;
else if 3721 <= &sic <= 3721 then &newvarname = 13 ;
else if 3724 <= &sic <= 3724 then &newvarname = 13 ;
else if 3725 <= &sic <= 3725 then &newvarname = 13 ;
else if 3728 <= &sic <= 3728 then &newvarname = 13 ;
else if 3730 <= &sic <= 3731 then &newvarname = 13 ;
else if 3732 <= &sic <= 3732 then &newvarname = 13 ;
else if 3740 <= &sic <= 3743 then &newvarname = 13 ;
else if 3760 <= &sic <= 3769 then &newvarname = 13 ;
else if 3790 <= &sic <= 3790 then &newvarname = 13 ;
else if 3795 <= &sic <= 3795 then &newvarname = 13 ;
else if 3799 <= &sic <= 3799 then &newvarname = 13 ;
else if 4000 <= &sic <= 4013 then &newvarname = 13 ;
else if 4100 <= &sic <= 4100 then &newvarname = 13 ;
else if 4110 <= &sic <= 4119 then &newvarname = 13 ;
else if 4120 <= &sic <= 4121 then &newvarname = 13 ;
else if 4130 <= &sic <= 4131 then &newvarname = 13 ;
else if 4140 <= &sic <= 4142 then &newvarname = 13 ;
else if 4150 <= &sic <= 4151 then &newvarname = 13 ;
else if 4170 <= &sic <= 4173 then &newvarname = 13 ;
else if 4190 <= &sic <= 4199 then &newvarname = 13 ;
else if 4200 <= &sic <= 4200 then &newvarname = 13 ;
else if 4210 <= &sic <= 4219 then &newvarname = 13 ;
else if 4220 <= &sic <= 4229 then &newvarname = 13 ;
else if 4230 <= &sic <= 4231 then &newvarname = 13 ;
else if 4400 <= &sic <= 4499 then &newvarname = 13 ;
else if 4500 <= &sic <= 4599 then &newvarname = 13 ;
else if 4600 <= &sic <= 4699 then &newvarname = 13 ;
else if 4700 <= &sic <= 4700 then &newvarname = 13 ;
else if 4710 <= &sic <= 4712 then &newvarname = 13 ;
else if 4720 <= &sic <= 4729 then &newvarname = 13 ;
else if 4730 <= &sic <= 4739 then &newvarname = 13 ;
else if 4740 <= &sic <= 4742 then &newvarname = 13 ;
else if 4780 <= &sic <= 4780 then &newvarname = 13 ;
else if 4783 <= &sic <= 4783 then &newvarname = 13 ;
else if 4785 <= &sic <= 4785 then &newvarname = 13 ;
else if 4789 <= &sic <= 4789 then &newvarname = 13 ;
else if 4900 <= &sic <= 4900 then &newvarname = 14 ;
else if 4910 <= &sic <= 4911 then &newvarname = 14 ;
else if 4920 <= &sic <= 4922 then &newvarname = 14 ;
else if 4923 <= &sic <= 4923 then &newvarname = 14 ;
else if 4924 <= &sic <= 4925 then &newvarname = 14 ;
else if 4930 <= &sic <= 4931 then &newvarname = 14 ;
else if 4932 <= &sic <= 4932 then &newvarname = 14 ;
else if 4939 <= &sic <= 4939 then &newvarname = 14 ;
else if 4940 <= &sic <= 4942 then &newvarname = 14 ;
else if 5260 <= &sic <= 5261 then &newvarname = 15 ;
else if 5270 <= &sic <= 5271 then &newvarname = 15 ;
else if 5300 <= &sic <= 5300 then &newvarname = 15 ;
else if 5310 <= &sic <= 5311 then &newvarname = 15 ;
else if 5320 <= &sic <= 5320 then &newvarname = 15 ;
else if 5330 <= &sic <= 5331 then &newvarname = 15 ;
else if 5334 <= &sic <= 5334 then &newvarname = 15 ;
else if 5390 <= &sic <= 5399 then &newvarname = 15 ;
else if 5400 <= &sic <= 5400 then &newvarname = 15 ;
else if 5410 <= &sic <= 5411 then &newvarname = 15 ;
else if 5412 <= &sic <= 5412 then &newvarname = 15 ;
else if 5420 <= &sic <= 5421 then &newvarname = 15 ;
else if 5430 <= &sic <= 5431 then &newvarname = 15 ;
else if 5440 <= &sic <= 5441 then &newvarname = 15 ;
else if 5450 <= &sic <= 5451 then &newvarname = 15 ;
else if 5460 <= &sic <= 5461 then &newvarname = 15 ;
else if 5490 <= &sic <= 5499 then &newvarname = 15 ;
else if 5540 <= &sic <= 5541 then &newvarname = 15 ;
else if 5550 <= &sic <= 5551 then &newvarname = 15 ;
else if 5600 <= &sic <= 5699 then &newvarname = 15 ;
else if 5700 <= &sic <= 5700 then &newvarname = 15 ;
else if 5710 <= &sic <= 5719 then &newvarname = 15 ;
else if 5720 <= &sic <= 5722 then &newvarname = 15 ;
else if 5730 <= &sic <= 5733 then &newvarname = 15 ;
else if 5734 <= &sic <= 5734 then &newvarname = 15 ;
else if 5735 <= &sic <= 5735 then &newvarname = 15 ;
else if 5736 <= &sic <= 5736 then &newvarname = 15 ;
else if 5750 <= &sic <= 5750 then &newvarname = 15 ;
else if 5800 <= &sic <= 5813 then &newvarname = 15 ;
else if 5890 <= &sic <= 5890 then &newvarname = 15 ;
else if 5900 <= &sic <= 5900 then &newvarname = 15 ;
else if 5910 <= &sic <= 5912 then &newvarname = 15 ;
else if 5920 <= &sic <= 5921 then &newvarname = 15 ;
else if 5930 <= &sic <= 5932 then &newvarname = 15 ;
else if 5940 <= &sic <= 5940 then &newvarname = 15 ;
else if 5941 <= &sic <= 5941 then &newvarname = 15 ;
else if 5942 <= &sic <= 5942 then &newvarname = 15 ;
else if 5943 <= &sic <= 5943 then &newvarname = 15 ;
else if 5944 <= &sic <= 5944 then &newvarname = 15 ;
else if 5945 <= &sic <= 5945 then &newvarname = 15 ;
else if 5946 <= &sic <= 5946 then &newvarname = 15 ;
else if 5947 <= &sic <= 5947 then &newvarname = 15 ;
else if 5948 <= &sic <= 5948 then &newvarname = 15 ;
else if 5949 <= &sic <= 5949 then &newvarname = 15 ;
else if 5960 <= &sic <= 5963 then &newvarname = 15 ;
else if 5980 <= &sic <= 5989 then &newvarname = 15 ;
else if 5990 <= &sic <= 5990 then &newvarname = 15 ;
else if 5992 <= &sic <= 5992 then &newvarname = 15 ;
else if 5993 <= &sic <= 5993 then &newvarname = 15 ;
else if 5994 <= &sic <= 5994 then &newvarname = 15 ;
else if 5995 <= &sic <= 5995 then &newvarname = 15 ;
else if 5999 <= &sic <= 5999 then &newvarname = 15 ;
else if 6010 <= &sic <= 6019 then &newvarname = 16 ;
else if 6020 <= &sic <= 6020 then &newvarname = 16 ;
else if 6021 <= &sic <= 6021 then &newvarname = 16 ;
else if 6022 <= &sic <= 6022 then &newvarname = 16 ;
else if 6023 <= &sic <= 6023 then &newvarname = 16 ;
else if 6025 <= &sic <= 6025 then &newvarname = 16 ;
else if 6026 <= &sic <= 6026 then &newvarname = 16 ;
else if 6028 <= &sic <= 6029 then &newvarname = 16 ;
else if 6030 <= &sic <= 6036 then &newvarname = 16 ;
else if 6040 <= &sic <= 6049 then &newvarname = 16 ;
else if 6050 <= &sic <= 6059 then &newvarname = 16 ;
else if 6060 <= &sic <= 6062 then &newvarname = 16 ;
else if 6080 <= &sic <= 6082 then &newvarname = 16 ;
else if 6090 <= &sic <= 6099 then &newvarname = 16 ;
else if 6100 <= &sic <= 6100 then &newvarname = 16 ;
else if 6110 <= &sic <= 6111 then &newvarname = 16 ;
else if 6112 <= &sic <= 6112 then &newvarname = 16 ;
else if 6120 <= &sic <= 6129 then &newvarname = 16 ;
else if 6140 <= &sic <= 6149 then &newvarname = 16 ;
else if 6150 <= &sic <= 6159 then &newvarname = 16 ;
else if 6160 <= &sic <= 6163 then &newvarname = 16 ;
else if 6172 <= &sic <= 6172 then &newvarname = 16 ;
else if 6199 <= &sic <= 6199 then &newvarname = 16 ;
else if 6200 <= &sic <= 6299 then &newvarname = 16 ;
else if 6300 <= &sic <= 6300 then &newvarname = 16 ;
else if 6310 <= &sic <= 6312 then &newvarname = 16 ;
else if 6320 <= &sic <= 6324 then &newvarname = 16 ;
else if 6330 <= &sic <= 6331 then &newvarname = 16 ;
else if 6350 <= &sic <= 6351 then &newvarname = 16 ;
else if 6360 <= &sic <= 6361 then &newvarname = 16 ;
else if 6370 <= &sic <= 6371 then &newvarname = 16 ;
else if 6390 <= &sic <= 6399 then &newvarname = 16 ;
else if 6400 <= &sic <= 6411 then &newvarname = 16 ;
else if 6500 <= &sic <= 6500 then &newvarname = 16 ;
else if 6510 <= &sic <= 6510 then &newvarname = 16 ;
else if 6512 <= &sic <= 6512 then &newvarname = 16 ;
else if 6513 <= &sic <= 6513 then &newvarname = 16 ;
else if 6514 <= &sic <= 6514 then &newvarname = 16 ;
else if 6515 <= &sic <= 6515 then &newvarname = 16 ;
else if 6517 <= &sic <= 6519 then &newvarname = 16 ;
else if 6530 <= &sic <= 6531 then &newvarname = 16 ;
else if 6532 <= &sic <= 6532 then &newvarname = 16 ;
else if 6540 <= &sic <= 6541 then &newvarname = 16 ;
else if 6550 <= &sic <= 6553 then &newvarname = 16 ;
else if 6611 <= &sic <= 6611 then &newvarname = 16 ;
else if 6700 <= &sic <= 6700 then &newvarname = 16 ;
else if 6710 <= &sic <= 6719 then &newvarname = 16 ;
else if 6720 <= &sic <= 6722 then &newvarname = 16 ;
else if 6723 <= &sic <= 6723 then &newvarname = 16 ;
else if 6724 <= &sic <= 6724 then &newvarname = 16 ;
else if 6725 <= &sic <= 6725 then &newvarname = 16 ;
else if 6726 <= &sic <= 6726 then &newvarname = 16 ;
else if 6730 <= &sic <= 6733 then &newvarname = 16 ;
else if 6790 <= &sic <= 6790 then &newvarname = 16 ;
else if 6792 <= &sic <= 6792 then &newvarname = 16 ;
else if 6794 <= &sic <= 6794 then &newvarname = 16 ;
else if 6795 <= &sic <= 6795 then &newvarname = 16 ;
else if 6798 <= &sic <= 6798 then &newvarname = 16 ;
else if 6799 <= &sic <= 6799 then &newvarname = 16 ;
else if 2520 <= &sic <= 2549 then &newvarname = 17 ;
else if 2600 <= &sic <= 2639 then &newvarname = 17 ;
else if 2640 <= &sic <= 2659 then &newvarname = 17 ;
else if 2661 <= &sic <= 2661 then &newvarname = 17 ;
else if 2670 <= &sic <= 2699 then &newvarname = 17 ;
else if 2700 <= &sic <= 2709 then &newvarname = 17 ;
else if 2710 <= &sic <= 2719 then &newvarname = 17 ;
else if 2720 <= &sic <= 2729 then &newvarname = 17 ;
else if 2730 <= &sic <= 2739 then &newvarname = 17 ;
else if 2740 <= &sic <= 2749 then &newvarname = 17 ;
else if 2750 <= &sic <= 2759 then &newvarname = 17 ;
else if 2760 <= &sic <= 2761 then &newvarname = 17 ;
else if 2770 <= &sic <= 2771 then &newvarname = 17 ;
else if 2780 <= &sic <= 2789 then &newvarname = 17 ;
else if 2790 <= &sic <= 2799 then &newvarname = 17 ;
else if 2835 <= &sic <= 2835 then &newvarname = 17 ;
else if 2836 <= &sic <= 2836 then &newvarname = 17 ;
else if 2990 <= &sic <= 2999 then &newvarname = 17 ;
else if 3000 <= &sic <= 3000 then &newvarname = 17 ;
else if 3010 <= &sic <= 3011 then &newvarname = 17 ;
else if 3041 <= &sic <= 3041 then &newvarname = 17 ;
else if 3050 <= &sic <= 3053 then &newvarname = 17 ;
else if 3160 <= &sic <= 3161 then &newvarname = 17 ;
else if 3170 <= &sic <= 3171 then &newvarname = 17 ;
else if 3172 <= &sic <= 3172 then &newvarname = 17 ;
else if 3190 <= &sic <= 3199 then &newvarname = 17 ;
else if 3220 <= &sic <= 3221 then &newvarname = 17 ;
else if 3229 <= &sic <= 3229 then &newvarname = 17 ;
else if 3230 <= &sic <= 3231 then &newvarname = 17 ;
else if 3260 <= &sic <= 3260 then &newvarname = 17 ;
else if 3262 <= &sic <= 3263 then &newvarname = 17 ;
else if 3269 <= &sic <= 3269 then &newvarname = 17 ;
else if 3295 <= &sic <= 3299 then &newvarname = 17 ;
else if 3537 <= &sic <= 3537 then &newvarname = 17 ;
else if 3640 <= &sic <= 3644 then &newvarname = 17 ;
else if 3645 <= &sic <= 3645 then &newvarname = 17 ;
else if 3646 <= &sic <= 3646 then &newvarname = 17 ;
else if 3647 <= &sic <= 3647 then &newvarname = 17 ;
else if 3648 <= &sic <= 3649 then &newvarname = 17 ;
else if 3660 <= &sic <= 3660 then &newvarname = 17 ;
else if 3661 <= &sic <= 3661 then &newvarname = 17 ;
else if 3662 <= &sic <= 3662 then &newvarname = 17 ;
else if 3663 <= &sic <= 3663 then &newvarname = 17 ;
else if 3664 <= &sic <= 3664 then &newvarname = 17 ;
else if 3665 <= &sic <= 3665 then &newvarname = 17 ;
else if 3666 <= &sic <= 3666 then &newvarname = 17 ;
else if 3669 <= &sic <= 3669 then &newvarname = 17 ;
else if 3840 <= &sic <= 3849 then &newvarname = 17 ;
else if 3850 <= &sic <= 3851 then &newvarname = 17 ;
else if 3991 <= &sic <= 3991 then &newvarname = 17 ;
else if 3993 <= &sic <= 3993 then &newvarname = 17 ;
else if 3995 <= &sic <= 3995 then &newvarname = 17 ;
else if 3996 <= &sic <= 3996 then &newvarname = 17 ;
else if 4810 <= &sic <= 4813 then &newvarname = 17 ;
else if 4820 <= &sic <= 4822 then &newvarname = 17 ;
else if 4830 <= &sic <= 4839 then &newvarname = 17 ;
else if 4840 <= &sic <= 4841 then &newvarname = 17 ;
else if 4890 <= &sic <= 4890 then &newvarname = 17 ;
else if 4891 <= &sic <= 4891 then &newvarname = 17 ;
else if 4892 <= &sic <= 4892 then &newvarname = 17 ;
else if 4899 <= &sic <= 4899 then &newvarname = 17 ;
else if 4950 <= &sic <= 4959 then &newvarname = 17 ;
else if 4960 <= &sic <= 4961 then &newvarname = 17 ;
else if 4970 <= &sic <= 4971 then &newvarname = 17 ;
else if 4991 <= &sic <= 4991 then &newvarname = 17 ;