|
1 | 1 | /************************************************************************************************
|
2 | 2 | USING FUNCTIONS TO CREATE FORMATS
|
3 |
| - This program creates a format based on fuctions created by PROC FCMP. |
| 3 | + This program creates a FORMAT based on functions created by PROC FCMP. |
4 | 4 | Keywords: PROC FORMAT, PROC FCMP, FORMAT, VALUE
|
5 | 5 | SAS Versions: SAS 9, SAS Viya
|
6 | 6 | Documentation: https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=default&docsetId=proc&docsetTarget=p1xidhqypi0fnwn1if8opjpqpbmn.htm
|
7 |
| - 1. Use PROC FCMP to create two new functions, start and end. |
8 |
| - 2. The Start function will take a date as its argument and from that date will go to the beginning of the week |
| 7 | + 1. Use PROC FCMP to create two new functions, START and END. |
| 8 | + 2. The START function will take a date as its argument and from that date will go to the beginning of the week |
9 | 9 | and then go forward to the next Monday (day 2 of the week.)
|
10 |
| - 3. The End function will go to the end of the next week, a Saturday. One is subtracted from the result so that the |
| 10 | + 3. The END function will go to the end of the next week, a Saturday. One is subtracted from the result so that the |
11 | 11 | End function returns a Friday.
|
12 | 12 | 4. The options statement tells SAS where to look for the new functions.
|
13 |
| - 5. The value statements in PROC FORMAT first identifies the name of the new format. The keyword other tells SAS |
| 13 | + 5. The VALUE statements in PROC FORMAT first identifies the name of the new format. The keyword OTHER tells SAS |
14 | 14 | to apply the format to all nonmissing values.
|
15 | 15 | 6. The square brackets surround the function to be used to define the format. In the start format the START function
|
16 | 16 | is used so that any date will be labeled as the Monday of the week of the date.
|
@@ -41,113 +41,23 @@ data orders;/*8*/
|
41 | 41 | infile cards;
|
42 | 42 | input CustomerID DeliveryDate : date9. OrderID;
|
43 | 43 | cards;
|
44 |
| -5 07MAY2011 1242140006 |
45 |
| -5 09MAY2011 1242159212 |
46 |
| -5 10JUN2011 1242493791 |
47 |
| -10 14JAN2010 1238231237 |
48 |
| -10 03FEB2010 1238393448 |
49 |
| -10 12MAR2010 1238686430 |
50 |
| -10 18SEP2010 1240201886 |
51 |
| -10 07OCT2010 1240355393 |
52 |
| -10 20OCT2010 1240461993 |
53 |
| -10 20OCT2010 1240461993 |
54 |
| -10 20OCT2010 1240461993 |
55 |
| -10 19MAR2011 1241686210 |
56 |
| -10 18APR2011 1242012259 |
57 |
| -10 18APR2011 1242012259 |
58 |
| -10 16MAY2011 1242265757 |
59 |
| -10 06JUN2011 1242458099 |
60 |
| -10 07JUL2011 1242736731 |
61 |
| -10 17JUL2011 1242827683 |
62 |
| -10 18JUL2011 1242836878 |
63 |
| -10 08AUG2011 1243026971 |
64 |
| -10 17AUG2011 1243110343 |
65 |
| -10 17AUG2011 1243110343 |
66 |
| -10 27AUG2011 1243198099 |
67 |
| -10 27AUG2011 1243198099 |
68 |
| -12 07MAR2010 1238646479 |
69 | 44 | 12 11MAR2010 1238678581
|
70 |
| -12 11MAR2010 1238678581 |
71 |
| -12 27APR2010 1239057268 |
72 |
| -12 03AUG2010 1239836937 |
73 |
| -12 08AUG2010 1239874523 |
74 |
| -12 05FEB2011 1241359997 |
75 | 45 | 12 23JUN2011 1242610991
|
76 | 46 | 13 28JUL2010 1239744161
|
77 |
| -13 28JUL2010 1239744161 |
78 |
| -16 20JUL2010 1239713046 |
79 |
| -16 20JUL2010 1239713046 |
80 | 47 | 16 20JUL2010 1239713046
|
81 |
| -16 17AUG2010 1239932984 |
82 |
| -16 17AUG2010 1239932984 |
83 |
| -16 08NOV2010 1240599396 |
84 |
| -16 08NOV2010 1240599396 |
85 |
| -16 23DEC2010 1240961599 |
86 |
| -16 23DEC2010 1240961599 |
87 |
| -17 02OCT2010 1240314956 |
| 48 | +16 02OCT2010 1240314956 |
88 | 49 | 18 17FEB2011 1241461856
|
89 | 50 | 19 06FEB2010 1238370259
|
90 |
| -19 13FEB2010 1238426415 |
91 |
| -19 01MAR2010 1238553101 |
92 |
| -19 26APR2010 1239003827 |
93 |
| -19 08NOV2010 1240568966 |
94 |
| -20 24MAY2010 1239226632 |
95 | 51 | 20 08NOV2010 1240613362
|
96 |
| -24 05JAN2011 1241054779 |
97 |
| -24 09MAR2011 1241623505 |
98 | 52 | 24 14JUL2011 1242773202
|
99 |
| -27 02FEB2011 1241286432 |
100 |
| -27 14MAR2011 1241652707 |
101 |
| -27 14APR2011 1241930625 |
102 |
| -27 14APR2011 1241930625 |
103 |
| -27 14APR2011 1241930625 |
104 |
| -27 10JUN2011 1242449327 |
105 |
| -27 17JUL2011 1242782701 |
106 |
| -27 10SEP2011 1243279343 |
107 |
| -29 21APR2010 1238968334 |
108 |
| -29 23APR2010 1238985782 |
109 |
| -29 16MAY2010 1239172417 |
110 |
| -29 22MAY2010 1239220388 |
111 |
| -29 15JUN2010 1239410348 |
112 |
| -29 21SEP2010 1240187143 |
113 |
| -29 23OCT2010 1240446608 |
114 |
| -29 23OCT2010 1240446608 |
115 |
| -29 28OCT2010 1240485814 |
116 |
| -31 31JAN2010 1238367238 |
117 |
| -31 18MAR2011 1241731828 |
118 |
| -31 18MAR2011 1241731828 |
119 |
| -31 29APR2011 1242076538 |
120 |
| -31 12JUN2011 1242477751 |
121 |
| -31 12JUN2011 1242477751 |
122 |
| -31 11JUN2011 1242502670 |
123 |
| -31 11JUN2011 1242502670 |
124 |
| -31 06SEP2011 1243290080 |
125 |
| -34 13JUN2011 1242467585 |
126 |
| -34 13JUN2011 1242467585 |
127 |
| -39 04APR2010 1238870441 |
128 |
| -39 17MAY2010 1239179935 |
129 |
| -41 10JAN2010 1238161695 |
130 |
| -41 02FEB2010 1238377562 |
131 |
| -41 23MAY2010 1239258470 |
132 |
| -41 19JUN2010 1239442095 |
133 |
| -41 09FEB2011 1241390440 |
134 |
| -41 08MAY2011 1242185055 |
135 |
| -41 19JUL2011 1242838815 |
136 |
| -41 19JUL2011 1242838815 |
137 |
| -41 10AUG2011 1243039354 |
138 |
| -45 29MAY2010 1239312711 |
139 |
| -45 29MAY2010 1239312711 |
140 |
| -45 06JUL2010 1239615368 |
141 |
| -45 18APR2011 1242012269 |
142 |
| -45 18APR2011 1242012269 |
143 |
| -45 27JUN2011 1242647539 |
| 53 | +24 21APR2010 1238968334 |
144 | 54 | ;
|
145 | 55 | run;
|
146 | 56 |
|
147 | 57 | proc report data=orders nowd;/*9*/
|
148 | 58 | columns CustomerID OrderID DeliveryDate ('Expected Delivery Between' DeliveryDate=DD1 DeliveryDate=DD2);
|
149 | 59 | define CustomerID / order 'Customer ID/' ;
|
150 |
| - define OrderID / 'Order ID/'; |
| 60 | + define OrderID / 'Order ID/' format=10.; |
151 | 61 | define DeliveryDate / display 'Actual Delivery' format=weekdate.;
|
152 | 62 | define DD1 / display 'Start' format=start12.;
|
153 | 63 | define DD2 / display 'End' format=end12.;
|
|
0 commit comments