-
Notifications
You must be signed in to change notification settings - Fork 0
/
me-comparison-market.sas
1883 lines (1598 loc) · 106 KB
/
me-comparison-market.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
/***************************************************************************/
/* ANTIDUMPING MARKET ECONOMY */
/* ANALYSIS OF COMPARISON MARKET SALES PROGRAM */
/* */
/* GENERIC VERSION LAST UPDATED AUGUST 13, 2024 */
/* */
/* Part 1: Database and General Program Information */
/* Part 2: Bring in Comparison Market Sales, Convert Date Variable, If */
/* Necessary, Merge Exchange Rates into CM Sales, As Required */
/* Part 3: Cost Information */
/* Part 4: Comparison Market Net Price Calculations */
/* Part 5: Arm's-Length Test of Affiliated Party Sales */
/* Part 6: Add the Downstream Sales for Affiliated Parties That Failed */
/* the Arm's-Length Test and Resold Merchandise */
/* Part 7: CM Values for CEP Profit Calculations */
/* Part 8: Cost Test */
/* Part 9: Weight-Averaged Comparison Market Values for Price-To-Price */
/* Comparisons with U.S. Sales */
/* Part 10: Calculate Selling Expense and Profit Ratios for */
/* Constructed-Value Comparisons */
/* Part 11: CM Level of Trade Adjustment */
/* Part 12: Delete All Work Files in the SAS Memory Buffer, If Desired */
/* Part 13: Calculate Run Time for This Program, If Desired */
/* Part 14: Review Log for Errors, Warnings, Uninitialized etc. */
/***************************************************************************/
/*-----------------------------------------------------------------------*/
/* EDITING THE PROGRAM: */
/* */
/* Places requiring edits are indicated by angle brackets (i.e., '< >'). */
/* Replace angle brackets with case-specific information. */
/* */
/* Types of Inputs: (D) = SAS dataset name */
/* (V) = Variable name */
/* (T) = Text (no specific format), */
/* do NOT use punctuation marks */
/* */
/* If there are angle brackets that are commented out, replacing the */
/* angles brackets with case specific code is optional. For example: */
/* */
/* <Insert changes here, if required.> */
/*-----------------------------------------------------------------------*/
/*---------------------------------------------------------------------*/
/* EXECUTING/RUNNING THE PROGRAM: */
/* */
/* In addition to executing the entire program, you can do */
/* partial runs. Executable points from which you can */
/* partially run the program are indicated by '/*ep*' on */
/* the left margin. To do a partial run, just highlight the */
/* program from one of the executable points to the top, */
/* then submit it. */
/*---------------------------------------------------------------------*/
/************************************************************************/
/* PART 1: DATABASE AND GENERAL PROGRAM INFORMATION */
/************************************************************************/
/*---------------------------------------------------------------------*/
/* 1-A: LOCATION OF DATA AND MACROS PROGRAM */
/* */
/* LIBNAME = The name (i.e., COMPANY) and location of the */
/* sub-directory containing the SAS datasets for */
/* this program. */
/* EXAMPLE: E:\Operations\Fiji\AR_2016\Hangers\Acme */
/* */
/* FILENAME = Full path of the Macro Program for this case, */
/* consisting of the sub-directory containing the */
/* Macro Program and its file name. */
/*---------------------------------------------------------------------*/
LIBNAME COMPANY '<E:\....>'; /* (T) Location of company and */
/* exchange rate data sets. */
FILENAME MACR '<E:\...\ME Macros.sas>'; /* (T) Location & name of AD-ME */
/* All Macros Program. */
%INCLUDE MACR; /* Use the AD-ME All Macros */
/* Program. */
FILENAME C_MACS '<E:\...\Common Macros.sas>'; /* (T) Location & Name of the */
/* Common Macros Program */
%INCLUDE C_MACS; /* Use the Common Macros */
/* Program. */
%LET LOG_SUMMARY = YES; /* Default value is "YES" (no */
/* quotes). Use "NO" (no quotes) */
/* to run program in parts for */
/* troubleshooting. */
/*------------------------------------------------------------------*/
/* GET PROGRAM PATH/NAME AND CREATE THE SAME NAME FOR THE LOG FILE */
/* WITH .LOG EXTENSION */
/*------------------------------------------------------------------*/
%GLOBAL MNAME LOG;
%LET MNAME = %SYSFUNC(SCAN(%SYSFUNC(PATHNAME(C_MACS)), 1, '.'));
%LET LOG = %SYSFUNC(SUBSTR(&MNAME, 1, %SYSFUNC(LENGTH(&MNAME)) - %SYSFUNC(INDEXC(%SYSFUNC(
REVERSE(%SYSFUNC(TRIM(&MNAME)))), '\'))))%STR(\)%SYSFUNC(DEQUOTE(&_CLIENTTASKLABEL.))%STR(.LOG);
%CMAC1_WRITE_LOG;
/*------------------------------------------------------------------*/
/* 1-B: PROCEEDING TYPE */
/*------------------------------------------------------------------*/
/*-----------------------------------------------*/
/* TYPE IN EITHER THE WORD 'AR' (NOT 1ST REVIEW) */
/* OR THE WORD 'INV'. DO NOT TYPE THE QUOTES. */
/*-----------------------------------------------*/
%LET CASE_TYPE = <AR/INV>; /*(T) For an investigation, type 'INV' */
/* (without quotes) */
/* For an administrative review, */
/* type 'AR' (without quotes) */
/*------------------------------------------*/
/* TYPE IN THE CASE NUMBER (EX. A-357-812). */
/*------------------------------------------*/
%LET CASE_NUMBER = < >; /*(T) Case Number */
/*-------------------------*/
/* TYPE IN YOUR FULL NAME. */
/*-------------------------*/
%LET PROGRAMMER = < >; /*(T) Case Analyst responsible for programming */
/*--------------------------------------------------------------------*/
/* 1-C: DATE INFORMATION */
/* */
/* Dates should be written in SAS DATE9 format (e.g., 01JAN2020). */
/* */
/* HMSALEDATE: */
/* */
/* The date of sale variable defined by the macro variable */
/* HMSALEDATE will be used to capture all CM sales within the date */
/* range specified by the macro variables HMBEGINDAY and HMENDAY. */
/* */
/* HMDATEBEFORESALE and HMEARLIERDATE: */
/* */
/* If there are reported dates before the sale date and you want */
/* the earlier dates to be assigned to sale date, define the macro */
/* variable HMDATEBEFORESALE to 'YES' and assign the variable with */
/* earlier dates to the macro variable HMEARLIERDATE (ex. SHIPDATH). */
/* Otherwise define the macro variable HMDATEBEFORESALE to 'NO' and */
/* ignore the macro variable HMEARLIERDATE. */
/* */
/* HMBEGINDAY and HMENDDAY: */
/* */
/* Define the macro variables HMBEGINDAY and HMENDDAY to correspond */
/* to the universe of CM sales that you want to use. */
/* */
/* For Investigations HMBEGINDAY often corresponds to the first day */
/* of the first month of the period and HMENDDAY often corresponds to */
/* the last day of the last month of the period, respectively, */
/* covering all U.S. sales dates. */
/* */
/* For Reviews HMBEGINDAY often corresponds to the first day of the */
/* first month of the window (i.e., 3 months before month of first */
/* reported U.S. sale date) and HMENDDAY often corresponds to the */
/* last day of the last month of the window (i.e., 2 months after */
/* month of last reported U.S. sale date). */
/* */
/* QUARTERLY COMPARISONS: When making quarterly price-to-price */
/* comparisons of CM and U.S. sales, comparisons are not made outside */
/* of designated time periods. In such cases, set HMBEGINDAY to the */
/* first day of the first time period and set HMENDDAY to the last */
/* day of the last time period. */
/* */
/* Note: In a review the CM macro variable HMBEGINDAY needs to have */
/* the same value as the ME Margin Calculation Program macro variable */
/* BEGINWINDOW so that model matching will work properly. */
/*--------------------------------------------------------------------*/
%LET HMSALEDATE = < >; /* (V) Variable representing the */
/* CM sale date. */
%LET HMDATEBEFORESALE = <YES/NO>; /* (T) Adjust sale date based on */
/* an earlier date variable? */
/* Type 'YES' (no quotes) to */
/* adjust the sale date, or */
/* 'NO' to skip this part. */
/* If you typed 'YES' then */
/* also complete the macro */
/* variable HMEARLIERDATE. */
%LET HMEARLIERDATE = < >; /* (V) Variable representing the */
/* earlier date variable. */
/* Note: In a review the CM macro variable HMBEGINDAY needs to have */
/* the same value as the Margin Calculation macro variable */
/* HMBEGINWINDOW so that model matching will work properly. */
%LET HMBEGINDAY = <DDMONYYYY>; /* (T) Please see above 1-C: DATE */
/* INFORMATION for guidance. */
%LET HMENDDAY = <DDMONYYYY>; /* (T) Please see above 1-C: DATE */
/* INFORMATION for guidance. */
/*-------------------------------------------------------------------------*/
/* 1-D: TITLES, FOOTNOTES AND AUTOMATIC NAMES FOR OUTPUT DATASETS */
/*-------------------------------------------------------------------------*/
%LET PRODUCT = %NRBQUOTE(<Product under Investigation or Review>); /*(T) Product */
%LET COUNTRY = %NRBQUOTE(<Country under Investigation or Review>); /*(T) Country */
/*-------------------------------------------------------------------------*/
/* The macro variables BEGINPERIOD and ENDPERIOD refer to the beginning */
/* and at the end of the official POI/POR. They are used for titling. */
/* BEGINPERIOD is also used in the Cohens d Test. */
/* */
/* Typically, these dates refer to the first day of the first month for */
/* the POI/POR for the BEGINPERIOD and the last day of the last month of */
/* the POI/POR for the ENDPERIOD. However, for first administrative */
/* reviews BEGINPERIOD is dependent on the injury results of the */
/* International Trade Commission (ITC) and the first day of suspension of */
/* liquidation. Please confirm the BEGINPERIOD with the Federal Register */
/* Notice initiating the first administrative review. */
/*-------------------------------------------------------------------------*/
%LET BEGINPERIOD = <DDMONYYYY>; /* (T) First day of the official POI/POR. */
%LET ENDPERIOD = <DDMONYYYY>; /* (T) Last day of the official POI/POR. */
/*------------------------------------------------------------------------*/
/* Between the RESPONDENT, SEGMENT and STAGE macro variables below, there */
/* should be a maximum of 21 digits. */
/*------------------------------------------------------------------------*/
%LET RESPONDENT = < >; /*(T) Respondent identifier. Use only letters, numbers */
/* and underscores. No punctuation marks, blank */
/* spaces or special characters should be used. */
%LET SEGMENT = < >; /*(T) Segment of the proceeding, e.g., Invest, AR1, */
/* Remand. Use only letters, numbers and underscores */
/* No punctuation marks, blank spaces or special */
/* characters should be used. */
%LET STAGE = < >; /*(T) Stage of proceeding, e.g., Prelim, Final, Remand. */
/* Use only letters, numbers and underscores. No */
/* punctuation marks, blank spaces or special */
/* characters should be used. */
/*-------------------------------------------------------------------*/
/* 1-E: DATABASE INFORMATION FOR CM SALES, COSTS & EXCHANGE RATES */
/* */
/* Where information may not be relevant (e.g., re: manufacturer */
/* and prime/non-prime merchandise), 'NA' (not applicable) will */
/* appear as the default value. */
/*-------------------------------------------------------------------*/
/*---------------------------------------------------------------*/
/* 1-E-i. EXCHANGE RATE INFORMATION: */
/* */
/* The CM program needs to use exchange rates if there are */
/* reported adjustments in non-CM currency. If there are */
/* no non-CM currencies, define the macro variables */
/* USE_EXRATES1 and USE_EXRATES2 as NO. */
/* */
/* If there are non-CM currencies, define the macro */
/* variable USE_EXRATES1 as YES for the first non-CM */
/* currency and define the macro variable EXDATA1 as the */
/* name of the exchange rate dataset. If there is a second */
/* non-CM currency, define the macro variable USE_EXRATES2 */
/* as YES and define the macro variable EXDATA2 as the */
/* name of the second exchange rate dataset. If there are */
/* more than two non-CM currencies, please contact a SAS */
/* Support Team member for assistance. */
/* */
/* When non-CM currencies are reported, there are three */
/* ways to refer to exchange rate variables in your */
/* CM Program. If the first non-CM currency is */
/* from Mexico, you can code the first exchange rate */
/* variable as EXRATE_MEXICO, &EXRATE1, or EXRATE_&EXDATA1. */
/* If the second non-CM currency is from Canada, you can */
/* code the second exchange rate variable as EXRATE_CANADA, */
/* &EXRATE2, or EXRATE_&EXDATA2. */
/* */
/* Non-CM currency variables need to be carried over to the */
/* Margin program in their original currency. You must */
/* update section 9-B-i in the CM program, as well as */
/* sections 1-E-i, 1-E-v, and Part 5 of the Margin program. */
/* Instructions for filling out those sections are */
/* contained at the beginning of the relevant section. */
/* */
/* NOTE: This program assumes that you are converting */
/* everything into the currency in which costs are */
/* reported. If this is not the case, please */
/* contact a SAS Support Team member for assistance. */
/*---------------------------------------------------------------*/
%LET USE_EXRATES1 = <YES/NO>; /*(T) Use exchange rate #1? Type "YES" or */
/* "NO" (without quotes). */
%LET EXDATA1 = < >; /*(D) Exchange rate dataset name. */
%LET USE_EXRATES2 = <YES/NO>; /*(T) Use exchange rate #2? Type "YES" or */
/* "NO" (without quotes). */
%LET EXDATA2 = < >; /*(D) Exchange rate dataset name. */
/*--------------------------------------------------------*/
/* 1-E-ii. COMPARISON MARKET INFORMATION */
/*--------------------------------------------------------*/
%LET HMDATA = < >; /*(D) CM sales dataset filename. */
%LET HMBARCODE = < >; /*(T) Bar code number(s) of CM sales */
/* dataset(s) used in this program. */
%LET HMCONNUM = < >; /*(V) Control number */
%LET HMCPPROD = < >; /*(V) Variable (usually CONNUMH) linking */
/* sales to cost data. */
/* Note: For model matching to work, physical characteristic variables */
/* need to be defined as all character or all numeric. Physical */
/* characteristic variable values need to be all numeric. */
%LET HMCHAR = < >; /*(V) Product matching characteristics. */
/* List them from left to right */
/* in order of importance, with spaces */
/* separating them. Do not surround the */
/* values with quotes. */
%LET HMQTY = < >; /*(V) Quantity. */
%LET HMGUP = < >; /*(V) Gross price. Need not be in */
/* consistent currency, used only to */
/* check for zero, negative & missing */
/* values. */
%LET HMLOT = <NA>; /*(V) Level of trade. If not reported in */
/* the database and not required, type */
/* "NA" (without quotes). */
/* You may also type "NA" if CM & US */
/* both have only 1 LOT & those LOTs */
/* are the same. */
/* Note: Specify a CM manufacturer variable if there is also a */
/* manufacturer variable reported in the U.S. sales. */
%LET HMMANUF = <NA>; /*(V) Manufacturer code. If not */
/* applicable, type "NA" (without */
/* quotes). */
/* Note: Specify a CM prime variable if there is also a prime */
/* variable reported in the U.S. sales. */
%LET HMPRIME = <NA>; /*(V) Prime/seconds code. If not */
/* applicable, type "NA" (without */
/* quotes). */
%LET HM_MULTI_CUR = <YES/NO>; /*(T) Is CM data in more than one */
/* currency? Type "YES" or "NO" */
/* (without quotes). */
%LET MIXEDCURR = <YES/NO/NA>; /*(T) Are there mixed-currency variables */
/* that need to be split into separate */
/* currency variables? */
/* Type "NO" (without quotes) if there */
/* is no mixed-currency variable. */
/* Type "YES" (without quotes) if there */
/* are mixed-currency variables AND */
/* there is currency-indicating */
/* variable (see 4-A below). */
/* Type "NA" (without quotes) if there */
/* are mixed-currency variables BUT */
/* there is no currency-indicating */
/* variable (see 4-A below). */
/*---------------------------------------------------------------*/
/* 1-E-iii. COST OF PRODUCTION DATA */
/* */
/* If the respondent has reported both a CM COP database and */
/* a U.S. CV database, it is best to combine them below in */
/* Part 3 and calculate one weight-averaged cost database. */
/*---------------------------------------------------------------*/
%LET COST_DATA = < >; /*(D) Cost dataset name */
%LET COSTBARCODE = < >; /*(T) Bar code number(s) of cost */
/* dataset(s) used in this program. */
%LET COST_MATCH = < >; /*(V) The variable (usually CONNUM) */
/* linking cost data to sales data. */
%LET COST_QTY = < >; /*(V) Production quantity */
/* Note: Specify a Cost manufacturer if there is also a manufacturer */
/* reported in the U.S. sales. */
/* */
/* If applicable, the cost manufacturer variable will be identified */
/* in the cost data file. This occurs in cases where the respondent */
/* is reporting the costs for a manufacturer of the merchandise under */
/* consideration that is not collapsed with the respondent. If there */
/* is no cost manufacturer variable included in the cost database, */
/* use "NA". */
/* */
/* The cost manufacturer variable identifies the respondent and any */
/* manufacturer other than the respondent that is not collapsed with */
/* the respondent. This is different from those instances where a */
/* respondent has more than one producing entity and we consider the */
/* producing entity to be part of the respondent (i.e., the producing */
/* entities are collapsed with the respondent). In such instances, */
/* the respondent may submit a cost data file for each producing */
/* entity, and we will weight-average those costs. */
%LET COST_MANUF = <NA>; /*(V) Manufacturer code. If not */
/* applicable, type "NA" (without */
/* quotes). */
/* Note: Specify a Cost prime variable if there is also a prime */
/* variable reported in the CM and U.S. sales. */
%LET COST_PRIME = <NA>; /*(V) Prime code. If not applicable, */
/* type "NA" (without quotes). */
/********************************************************************/
/* If there are quarterly costs (Section 1-E-iii-a.) and/or the */
/* need to find surrogate costs (Section 1-E-iii-b.) but there are */
/* no product matching characteristics in cost data, fill in the */
/* following six macro variables. Otherwise leave them blank. */
/********************************************************************/
%LET USDATA = < >; /*(D) U.S. sales dataset filename, needed */
/* if there are quarterly costs and/or */
/* the need to find surrogate costs and */
/* there are no product matching */
/* characteristics in cost data. */
%LET USBARCODE = < >; /*(T) Bar code number(s) of US sales */
/* dataset(s) used in this program. */
%LET USCONNUM = < >; /*(V) Control number */
%LET USQTY = < >; /*(V) Quantity */
%LET USGUP = < >; /*(V) Gross price. Need not be in consistent */
/* currency, used only to check for zero, */
/* negative and missing values. */
%LET USBEGINDAY = < >; /*(T) Please see above 1-C: DATE INFORMATION */
/* in ME Margin Program for guidance. */
%LET USENDDAY = < >; /*(T) Please see above 1-C: DATE INFORMATION */
/* in ME Margin Program for guidance. */
/*----------------------------------------------------*/
/* 1-E-iii-a. SURROGATE COSTS FOR NON-PRODUCTION */
/* */
/* If you have products that were sold but not */
/* produced during the period and that do not already */
/* have adequate surrogate cost information reported, */
/* type 'YES' (without quotes)on the first line and */
/* complete the rest of this section. */
/*----------------------------------------------------*/
%LET MATCH_NO_PRODUCTION = <YES/NO>; /*(T) Find surrogate costs for */
/* products not produced during */
/* the POR? Type "YES" or "NO" */
/* (without quotes). If "YES," */
/* complete the indented macro */
/* variables that follow. */
%LET COST_PROD_CHARS = <YES/NO>; /*(T) Are the product physical */
/* characteristic variables in the */
/* cost database? Type "YES" or */
/* "NO" without quotes). */
/* Note: For model matching to work, physical characteristic variables */
/* need to be defined as all character or all numeric. Physical */
/* characteristic variable values need to be all numeric. */
%LET COST_CHAR = < >; /*(V) Product matching characteristics in cost */
/* data. List them from left-to-right in */
/* order of importance, with spaces */
/* separating them. Do not surround the */
/* values with quotes. If there are no */
/* product characteristics in cost data, */
/* complete the indented macro variables. */
%LET USCVPROD = < >; /*(V) Variable (usually CONNUMU) linking sales */
/* to cost data. Needed only if no product */
/* matching characteristics in cost data OR */
/* you are comparing by time. */
/* (Section 1-E-iii-a.) */
/* Note: For model matching to work, physical characteristic variables */
/* need to be defined as all character or all numeric. Physical */
/* characteristic variable values need to be all numeric. */
%LET USCHAR = < >; /*(V) Product matching characteristics in U.S. */
/* data. List them from left-to-right in */
/* order of importance, with spaces separat- */
/* ing them. Do not surrounded the values */
/* with quotes. Needed only if there are no */
/* product matching characteristics in the */
/* cost data. NOTE: If period cost is being */
/* run, matching characteristics must be */
/* included. */
%LET USMANF = <NA>; /*(V) U.S. manufacturer code. If not applicable, */
/* type "NA" (without quotes). */
%LET USPRIME = <NA>; /*(V) U.S. Prime/seconds code. If not */
/* applicable, type "NA" (without quotes). */
/*--------------------------------------------------*/
/* 1-E-iii-b. QUARTERLY COSTS */
/* */
/* If you type COMPARE_BY_TIME = YES on the first */
/* line, also complete the rest of this section. */
/*--------------------------------------------------*/
%LET COMPARE_BY_TIME = <YES/NO>; /*(T) Calculate costs by time */
/* periods? Type "YES" or "NO" */
/* (without quotes). */
/* Note: The cost time period variable needs to be defined as a two */
/* digit character variable. The cost time period variable values need */
/* to be all numeric and left justified. */
%LET COST_TIME_PERIOD = < >; /*(V) Variable in cost data for */
/* time periods. */
%LET TIME_INSIDE_POR = < >; /*(T) List of values of */
/* &COST_TIME_PERIOD variable */
/* for periods during the POR, */
/* separated by commas and */
/* surrounded by quotes. Values */
/* in the variables must be */
/* numbers, i.e. '-1', '0', */
/* '1', '2', '3', etc. */
%LET DIRMAT_VARS = < >; /*(V) List the direct materials */
/* variables in the cost */
/* dataset that will need to */
/* have average purchase */
/* cost(s). I.e. COIL ZINC */
/* SCRAPS. List the variables */
/* separately. Do not put them */
/* in quotes or separate them */
/* using commas. */
%LET TOTCOM = < >; /*(V) Reported total cost of */
/* manufacturing. Usually */
/* TOTCOM. */
%LET USSALEDATE = < >; /* (V) Variable representing the */
/* U.S. sale date. */
%LET USDATEBEFORESALE = <YES/NO>; /* (T) Adjust sale date based on */
/* an earlier date variable? */
/* Type 'YES' (no quotes) to */
/* adjust the sale date, or */
/* 'NO' to skip this part. */
/* If you typed 'YES' then */
/* also complete the macro */
/* variable USEARLIERDATE. */
%LET USEARLIERDATE = < >; /* (V) Variable representing the */
/* earlier date variable. */
/*--------------------------------------------------*/
/* 1-E-iii-c. HIGH INFLATION COSTS */
/* */
/* If you type COMPARE_BY_TIME = YES on the first */
/* line, also complete the rest of this section. */
/*--------------------------------------------------*/
%LET COMPARE_BY_HIGH_INFLATION = <YES/NO>; /*(T) Calculate high inflation? */
/* Type "YES" or "NO" */
/* (without quotes). */
%LET COST_YEAR_MONTH = < >; /*(V) Variable in Cost data */
/* representing year and month. */
%LET LAST_YEAR_MONTH = <yyyymm>; /*(T) Last year and month of the */
/* period in the form YYYYMM. */
/*----------------------------------------------------------------------*/
/* 1-F: CONDITIONAL PROGRAMMING OPTIONS: */
/* */
/* For each conditional programming macro below, select either */
/* YES (to run) or NO (not to run). The conditional programming */
/* macros all begin with %LET RUN_ and indicate that YES or NO */
/* answers are expected. Answer all YES/NO questions. */
/* */
/* If you select YES for THE RUN_ARMSLENGTH or RUN_DOWNSTREAM */
/* macro variables, also complete the indented macro variables */
/* that immediately follow THE RUN_ARMSLENGTH or RUN_DOWNSTREAM. */
/* */
/* Note: Results of the HMLOTADJ calculation are meaningless */
/* unless the following criteria are met: */
/* 1. There are two or more levels of trade in CM data */
/* 2. At least one of those two CM levels of trade also */
/* exist in the U.S. data. */
/*----------------------------------------------------------------------*/
%LET RUN_ARMSLENGTH = <YES/NO>; /*(T) Run the Arm's-Length test? Type */
/* "YES" or "NO" (without quotes). */
%LET HMCUST = < >; /*(V) Customer identifier/code */
%LET HMAFFL = < >; /*(V) Customer affiliation code */
%LET NAFVALUE = < 1 >; /*(T) Value in data indicating */
/* unaffiliated sales. Default is */
/* numeric value of 1. */
%LET RUN_DOWNSTREAM = <YES/NO>; /*(T) Include a downstream sales dataset? */
/* You must run the Arms-Length test */
/* to use downstream sales. Type "YES" */
/* or "NO" (without quotes). */
%LET DOWNSTREAMDATA = < >; /*(D) Downstream sales dataset filename. */
%LET RUN_HMCEPTOT = <YES/NO>; /*(T) Calculate CM revenue and expenses */
/* for CEP profit? Type "YES" or "NO" */
/* (without quotes). If you type "YES," */
/* you must have a cost database. */
%LET RUN_HMLOTADJ = <YES/NO>; /*(T) Run LOT price pattern calculation? */
/* Type "YES" or "NO" (without quotes). */
/*------------------------------------------------------------------*/
/* 1-G: FORMAT, PROGRAM AND PRINT OPTIONS */
/*------------------------------------------------------------------*/
/*-------------------------------------------------------------*/
/* 1-G-i Options that usually do not require edits. */
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
/* 1-G-i-a Printing Formats */
/* */
/* In sections where a large number of observations may */
/* print, the program limits the number of observations */
/* to 25, by default. To change this, adjust the PRINTOBS */
/* number below. */
/* */
/* By editing the default formats used below, you can */
/* change the way values are displayed when the formats */
/* are used. When you increase the number of decimals */
/* (the number to the right of the decimal in the format), */
/* you must also increase the maximum number of places */
/* displayed, which is the number to the left of the */
/* decimal. (Commas, decimal points, dollar signs, percent */
/* symbols, etc. all occupy space.) For example, the */
/* COMMA12.2 format looks like '1,000,000.00' To display */
/* four decimal places you would type "COMMA14.4" */
/*-------------------------------------------------------------*/
%LET PRINTOBS = 25; /*(T) Number of obs to print on */
/* statements that are sampled. */
%LET COMMA_FORMAT = COMMA12.2; /* Comma format using 12 total */
/* spaces and two decimal places. */
%LET DOLLAR_FORMAT = DOLLAR12.2; /* Dollar format using 12 total */
/* spaces and two decimal places. */
%LET PERCENT_FORMAT = PERCENT8.2; /* Percent format using seven total */
/* spaces and two decimal places. */
/*----------------------------------------------------------*/
/* 1-G-i-b Programming Options */
/*----------------------------------------------------------*/
%LET DEL_WORKFILES = NO; /*(T) Delete all work library files? Default */
/* is NO. If you type "YES" (without */
/* quotes), you may increase program speed, */
/* but will not be able examine files in */
/* the work library for diagnostic purposes. */
%LET CALC_RUNTIME = YES; /*(T) Calculate program run time? If you don't */
/* like to see this info., type "NO" (without */
/* quotes) */
OPTION NOSYMBOLGEN; /* SYMBOLGYN prints macro variable resolutions. */
/* Reset to "NOSYMBOLGEN" (without quotes) to */
/* deactivate. */
OPTION MPRINT; /* MPRINT prints macro resolutions, type */
/* "NOMPRINT" (without quotes) to deactivate. */
OPTION NOMLOGIC; /* MLOGIC prints additional info. on macros, */
/* type "MLOGIC" (without quotes) to activate. */
OPTION MINOPERATOR; /* MINOPERATOR is required when using the IN(..) */
/* function in macros. */
OPTION OBS = MAX; /* Indicates the number of OBS to process in each */
/* data set. Default setting of MAX processes all */
/* transactions. If you have large datasets and */
/* initially wish to debug the program using a */
/* limited number of transactions, you can reset */
/* this option by typing in a number. */
OPTION NODATE; /* Suppresses date in header */
OPTION PAGENO = 1; /* Restarts page numbering at Page 1 */
OPTION YEARCUTOFF = 1960; /* Specifies the first year of a 100-year span that */
/* is used to read a two-digit year */
OPTION SPOOL; /* Aids finding location of syntax error in macros */
OPTION VARINITCHK = ERROR; /* An uninitialized variable will generate an ERROR */
OPTION FORMCHAR = '|----|+|---+=|-/\<>*'; /* For printing tables */
/*------------------------------------------------------------------*/
/* 1-H: GENERATE PROGRAM-SPECIFIC TITLES, FOOTNOTES */
/* AND MACROS NEEDED TO EXECUTE THE PROGRAM. */
/*------------------------------------------------------------------*/
%LET SALESDB = HMSALES;
/*%G1_RUNTIME_SETUP*/
%G2_TITLE_SETUP
%G3_COST_TIME_MVARS
/*--------------------------------------------------------------------*/
/* 1-I: PRIME AND MANUFACTURER MACROS AND MACRO VARIABLES */
/* */
/* In the programming language, the macro variables HMPRIM, */
/* &HMMANF and COPMANF are used. Their values are determined */
/* by the answers in Sect.1-E-ii above. */
/* For example, if you typed %LET HMMANUF=NA, then the macro */
/* variable HMMANF will be set to a null/blank value. */
/* Otherwise, HMMANF will be equal to the variable specified */
/* in %LET HMMANUF=<???>. */
/* */
/* Similarly, HMPRIM and COPMANF will either be a null/blank */
/* values, or set equal to the variables specified in */
/* %LET HMPRIME=<???> and %LET COPMANUF=<???>. */
/*--------------------------------------------------------------------*/
%HM1_PRIME_MANUF_MACROS
/*************************************************************************/
/* PART 2: BRING IN COMPARISON MARKET SALES, CONVERT DATE VARIABLE, */
/* IF NECESSARY, MERGE EXCHANGE RATES INTO CM SALES, AS REQUIRED */
/*************************************************************************/
/*----------------------------------------------------------------------*/
/* 2-A: BRING IN COMPARISON MARKET SALES */
/* */
/* Alter the SET statement, if necessary, to bring in more */
/* than one SAS database. If you need to rename variables, */
/* change variables from character to numeric (or vice versa), */
/* in order to do align the various databases, make such */
/* changes here. */
/* */
/* Changes to CM data using exchange rates and costs should */
/* wait until Part 4, below, after the cost and exchange rate */
/* databases are attached. */
/* */
/* Leave the data step open through the RUN statement */
/* following the execution of the G4_LOT macro in Sect 2-C-ii */
/*----------------------------------------------------------------------*/
DATA HMSALES;
SET COMPANY.&HMDATA;
&HMSALEDATE = FLOOR(&HMSALEDATE); /* Eliminates the time part of sale date when defined as a datetime variable. */
/* Selectively adjust sale date based on an earlier date variable. */
%DEFINE_SALE_DATE (SALEDATE = &HMSALEDATE, DATEBEFORESALE = &HMDATEBEFORESALE, EARLIERDATE = &HMEARLIERDATE);
/*------------------------------------------------------------------*/
/* 2-B: Insert and annotate any changes below. */
/*------------------------------------------------------------------*/
/* <Insert changes here, if required.> */
/*-----------------------------------------------------------------------
/* 2-C: LEVEL OF TRADE */
/* */
/* The variable HMLOT will be created containing the levels */
/* of trade. It is this variable that is used in the */
/* programming. If you typed '%LET HMLOT = NA' in */
/* Sect.1-E-ii above, the variable HMLOT will be set to 0 */
/* (zero). Otherwise, HMLOT will be set equal to the variable */
/* specified in %LET HMLOT = <???>. */
/*---------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/* 2-C-i: MAKE CHANGES TO LEVEL OF TRADE, IF REQUIRED */
/*------------------------------------------------------------------*/
/*-----------------------------------------------------------*/
/* If you have a level of trade variable and need to make */
/* changes to its values, or you don't have one but need to */
/* create one, make those edits here before the %G4_LOT. */
/*-----------------------------------------------------------*/
/* < Make changes to/create LOT variable, if required > */
/*------------------------------------------------------------------*/
/* 2-C-ii: CREATE THE LEVEL OF TRADE PROGRAMMING VARIABLE */
/*------------------------------------------------------------------*/
%G4_LOT(&HMLOT,HMLOT)
%CREATE_QUARTERS(&HMSALEDATE, HM) /* Assigns quarters to CM sales based on */
/* the date of sale variable and the */
/* first day of the POR/POI. The */
/* values will be '-1', '0', '1', etc. */
%CREATE_YEAR_MONTH(&HMSALEDATE, HM) /* In high inflation cases Creates the */
/* variable YEARMONTHH representing the */
/* year and month of sale date. */
RUN;
/*ep*/
/*------------------------------------------------------------------*/
/* 2-C-iii: GET CM SALES COUNT FOR LOG REPORTING */
/*------------------------------------------------------------------*/
%CMAC2_COUNTER (DATASET = COMPANY.&HMDATA, MVAR = ORIG_HMSALES);
/*ep*/
/*----------------------------------------------------------------------*/
/* 2-D: TEST FORMAT OF DATE VARIABLE AND CONVERT, WHEN NECESSARY */
/* */
/* This section tests the sale date variable to see if it is */
/* in SAS date format. If not, an attempt will be made to */
/* convert it using language that will work for many cases, */
/* but not all. Should the language not convert your data */
/* correctly, contact a SAS Support Team member for assistance.*/
/*----------------------------------------------------------------------*/
%G5_DATE_CONVERT
/*ep*/
/*---------------------------------------------------------------------*/
/* 2-E: CHECK FOR NEGATIVE AND MISSING DATA, AND FOR DATES */
/* OUTSIDE THE POI OR WINDOW. CREATE THE MONTH VARIABLE */
/* FOR AN ADMINISTRATIVE REVIEW. */
/* */
/* Sales with gross price or quantity variables that have */
/* missing values or values less than or equal to zero will */
/* be taken out of the database only to make the program */
/* run smoothly. This is not a policy decision. You may */
/* have to make adjustments to such sales. */
/* */
/* Sales outside the POI (for an investigation) or window */
/* period (for administrative reviews) will be set aside. */
/* */
/* In an administrative review, a month variable will be */
/* created giving each month in the window period a unique */
/* number. In the first calendar year of the review, the */
/* value of HMMONTH will be equal to the normal numeric */
/* month designation (e.g., Jan=1, Feb=2). In the second */
/* calendar year of the review, HMMONTH will be equal to */
/* the numeric month designation + 12 (e.g., Jan=1+12=13). */
/* Similarly, in a third calendar year, HMMONTH = month+24. */
/*---------------------------------------------------------------------*/
%G6_CHECK_SALES
/*ep*/
/*--------------------------------------------------------------------*/
/* 2-F: MERGE IN EXCHANGE RATES, AS REQUIRED */
/* */
/* For both potential exchange rates in Section I-E-i above, */
/* macro variables with neutral values are first created. */
/* These neutral values will be over-written with actual */
/* exchange rate data, as required. */
/*--------------------------------------------------------------------*/
%G7_EXRATES
/*ep*/
/*------------------------------------------------------------------*/
/* 2-G: READ IN U.S. DATASET FOR COST AND QUARTERLY COST PURPOSES */
/* */
/* Edits to U.S. control numbers and product characteristics */
/* should be done here. %READ_US will be executed in the */
/* G9_COST_PRODCHARS macro and in the G10_TIME_PROD_LIST macro, as */
/* needed. */
/*------------------------------------------------------------------*/
%MACRO READ_US;
DATA USSALES NEGDATA_US OUTDATES_US;
SET COMPANY.&USDATA;
&USSALEDATE = FLOOR(&USSALEDATE); /* Eliminates the time part of sale date when defined as a datetime variable. */
/* <Make changes to U.S. control numbers and product> */
/* <characteristic variables here, if required. > */
/* Selectively adjust sale date based on an earlier date variable. */
%DEFINE_SALE_DATE (SALEDATE = &USSALEDATE, DATEBEFORESALE = &USDATEBEFORESALE, EARLIERDATE = &USEARLIERDATE);
%CREATE_QUARTERS(&USSALEDATE, HM) /* Assigns quarters to US sales based on */
/* the date of sale variable and the */
/* first day of the POR/POI. The */
/* values will be '-1', '0', '1', etc. */
IF &USQTY LE 0 OR &USGUP LE 0 THEN
OUTPUT NEGDATA_US;
ELSE
IF "&USBEGINDAY."D GT &USSALEDATE OR &USSALEDATE GT "&USENDDAY."D THEN
OUTPUT OUTDATES_US;
/* %MARGIN_FILTER */
ELSE
OUTPUT USSALES;
RUN;
%MEND READ_US;
/******************************************************************/
/* PART 3: COST INFORMATION */
/* */
/* If the respondent has supplied separate COP and CV databases, */
/* combine them together in this program in sect. 3-B and make */
/* required adjustments. The combined weight-averaged cost */
/* database calculated in this program can then also be used in */
/* the Margin Program with U.S. sales. This is preferable to */
/* calculating the two individually. */
/* */
/* Make required changes to items in the indicated sections as */
/* needed: */
/* */
/* Section 3-A-i Major input adjustments */
/* Section 3-B-ii-a Align CM and U.S. CONNUMS, product chars. */
/* Section 3-C Cost of manufacturing, G&A, interest, and */
/* cost of production */
/******************************************************************/
/*--------------------------------------------------------------*/
/* 3-A CALL UP COST DATA, INCLUDING A SEPARATE CV DATABASE, */
/* IF PROVIDED. */
/* */
/* Make changes to cost inputs, manufacturer, etc., calculate */
/* major input adjustments. */
/* */
/* Do NOT make changes to GNA, INTEX or the calculation */
/* of TOTCOM here. Instead, do these below in Section 3-C. */
/* */
/* Also, do NOT reset missing or zero production quantities */
/* to positive values at this point with the exception noted */
/* in the next paragraph. The resetting of zero/missing */
/* production quantities before weight averaging will be done */
/* later in Section 3-C below. */
/* */
/* For annualized (not quarterly) costs, if the respondent */
/* has already provided surrogate cost information for a */
/* particular product but has put either a zero or a missing */
/* value for production quantity, then the default language */
/* in Section 3-B will mistakenly mark the product as one */
/* still requiring surrogate information. For annualized costs */
/* only, you can remedy this by setting the production quantity */
/* to a non-zero or non-missing value in Section 3-A-i. */
/* */
/* CONNUMUs in the CM and U.S. datasets that have sales but no */
/* production in the POI/POR must be in the COP dataset with a */
/* production quantity of 0 (zero). If respondent does not */
/* report these CONNUMs in the cost dataset, the analyst must */
/* add these CONNUMs to the COP dataset with a production */
/* quantity of 0 (zero). */
/*--------------------------------------------------------------*/
DATA COST;
SET COMPANY.&COST_DATA /* <COMPANY.CVDATABASE> */;
/*------------------------------------------------------------*/
/* 3-A-i: Insert and annotate any major input changes below. */
/* */
/* If there are quarterly costs, insert language for creating */
/* the cost time period variable. The variable needs to be */
/* defined as a two-digit character variable. The cost period */
/* variable values need to be all numeric and left justified. */
/* E.g. '-1', '0', '1', '2', etc. The first quarter of the */
/* POI/POR must be '1'. */
/*------------------------------------------------------------*/
/* <Insert major input changes here, if required.> */
RUN;
/*ep*/
/*--------------------------------------------------------------*/
/* 3-a-ii: GET COST COUNT FOR LOG REPORTING */
/*--------------------------------------------------------------*/
%CMAC2_COUNTER (DATASET = COMPANY.&COST_DATA, MVAR = ORIG_COST);
/*ep*/
/*--------------------------------------------------------------*/
/* 3-B SURROGATE COSTS FOR PRODUCTS NOT PRODUCED DURING POI/POR */
/*--------------------------------------------------------------*/
/*-------------------------------------------------------------*/
/* 3-B-i IDENTIFY PRODUCTS NOT PRODUCED DURING POI/POR */
/* FOR WHICH SURROGATE COSTS ARE NEEDED. */
/* */
/* The macro variable &FIND_SURROGATES will be created whose */
/* value will be "YES" when it does find products requiring */
/* surrogates using the criteria specified. Otherwise, */
/* &FIND_SURROGATES will be set to "NO," turning off sections */
/* 3-B-ii-a and 3-E. If &FIND_SURROGATES = NO, then you will */
/* not need to supply information in 3-B-ii-a on U.S. product */
/* characteristic variables. */
/* */
/* The %G8_FIND_NOPRODUCTION macro below identifies products */
/* needing surrogate cost information when total production */
/* during the annual cost period is zero or missing. If this */
/* assumption does not fit the circumstances, you will need */
/* to make edits accordingly. */
/* */
/* For annualized (not quarterly) costs, if the respondent */
/* has already provided surrogate cost information for a */
/* particular product but has put either a zero or a missing */
/* value for production quantity, then the default language */
/* will mistakenly think no surrogate information has been */
/* provided. For annualized costs only, you can remedy this */
/* problem by setting the production quantity to a non-zero or */
/* non-missing value above in section 3-A-i. */
/*-------------------------------------------------------------*/
%MACRO NOPRODUCTION;
%GLOBAL FIND_SURROGATES;
%LET FIND_SURROGATES = NO; /* Default value. Do not edit. */
%IF %UPCASE(&MATCH_NO_PRODUCTION) = YES %THEN
%DO;
%G8_FIND_NOPRODUCTION /* Finds products needing surrogate */
/* costs by looking for total produc- */
/* tion quantities per product that */
/* are less than or equal to zero, */
/* or have missing values. If this */
/* is incorrect, please make adjust- */
/* ments above in Section 3-A-i before */
/* executing the G8_FIND_NOPRODUCTION */
/* macro. */
/*---------------------------------------------------------*/
/* 3-B-ii ATTACH PRODUCT CHARACTERISTICS, WHEN REQUIRED */
/* */
/* When product characteristic variables are not in the */
/* data, they will be taken from both the CM and U.S. */
/* sales databases. To do this, the CM and U.S. control */
/* numbers must be of the same type (character v. numeric) */
/* and length, if character. Likewise for the product */
/* characteristic variables. If you need to make adjust- */
/* ments to the control numbers and/or product charac- */
/* teristic variables, do that here before the execution */
/* of the G9_COST_PRODCHARS macros below. */
/*---------------------------------------------------------*/
/*-------------------------------------------------------*/
/* 3-B-ii-a: Insert changes to control numbers and */
/* product characteristics in U.S. sales data. */
/* */