-
Notifications
You must be signed in to change notification settings - Fork 0
/
ages.tpl~
executable file
·275 lines (235 loc) · 11.3 KB
/
ages.tpl~
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
proc template;
/*-----------------------------------------------------------eric-*/
/*-- Define a minimalistic style that will stripe it's --*/
/*-- table rows. This is specifically to work with the --*/
/*-- striped html tagset. Any style can be modified to --*/
/*-- work with that tagset just by adding light and --*/
/*-- dark style elements. --*/
/*--------------------------------------------------------7Aug 03-*/
define Style styles.minimal_striped;
parent = styles.minimal;
style header/
font = (, 4,bold)
;
style Data/
font = (, 3,normal)
;
style DataStrong from data /
background=cxD5E5D2
;
style nobs_label from header /
font_size = 3
;
style table_head
;
style byline /
font_size = 5
font_weight = bold
;
replace Output /
BorderWidth = 0
CellSpacing = 1
CellPadding = 7
Frame = void
Rules = none
;
end;
/*---------------------------------------------------------------eric-*/
/*-- 3 tagsets. --*/
/*-- --*/
/*-- The idea is to create reusable code while --*/
/*-- addressing a job specific problem. The first two tagsets --*/
/*-- will work for any number of applications. The third is --*/
/*-- specific to particular problem and sas job. --*/
/*-- --*/
/*-- 1. striped. - this alternates between light and dark styles --*/
/*-- for each data row of a table. Starting with dark. --*/
/*-- --*/
/*-- If a title is provided on the ods statement, It will appear --*/
/*-- on the first page as a heading along with the date and time. --*/
/*-- --*/
/*-- 2. nobs_label - this one inherits from striped and adds a --*/
/*-- label above each table indicating how many observations are --*/
/*-- in the table. The event table_nobs_label can be modified --*/
/*-- to change the format. By default the labeling is turned off. --*/
/*-- It can be turned on at any time by setting the macro variable --*/
/*-- do_nobs_label to true. %let do_nobs_label true; --*/
/*-- --*/
/*-- 3. defects. This is a very specialized tagset that modifys --*/
/*-- the byline based upon the value of a macro variable. It also --*/
/*-- combines the byline with the nobs label to form one heading --*/
/*-- above the table. --*/
/*------------------------------------------------------------7Aug 03-*/
/*-----------------------------------------------------------eric-*/
/*-- This tagset adds an observation count to the top --*/
/*-- of the label. It does this by redirecting the --*/
/*-- table to an itemstore stream while it counts. --*/
/*-- Then it prints the label and then the stream. --*/
/*--------------------------------------------------------7Aug 03-*/
define tagset tagsets.nobs_label;
parent=tagsets.stripes;
mvar do_nobs_label;
/*-------------------------------------------------------eric-*/
/*-- Add the date and time to the document title. Save it --*/
/*-- away for later. --*/
/*----------------------------------------------------7Aug 03-*/
define event doc_title;
set $title body_title title ' - ' date " at " time;
putl '<TITLE>' $title '</TITLE>';
end;
define event doc_body;
start:
put '<body onload="startup()"';
put ' onunload="shutdown()"';
put ' bgproperties="fixed"' / WATERMARK;
putq " class=" HTMLCLASS;
putq " background=" BACKGROUNDIMAGE;
trigger style_inline;
put ">" nl;
trigger pre_post;
put nl;
trigger ie_check;
/*-----------------------------------------------eric-*/
/*-- This is the part that changed. --*/
/*-- Add in the title if we have one. --*/
/*--------------------------------------------7Aug 03-*/
do /if $title;
putl '<h3';
trigger align;
putl '>' $title '</h3>';
done;
finish:
trigger pre_post;
put "</body>" nl;
end;
define event output;
finish:
put "<br>" nl;
end;
define event table ;
start:
eval $nobs 0;
/*-----------------------------------------------eric-*/
/*-- if we aren't going to print the nobs label --*/
/*-- then there's no point in doing extra work. --*/
/*--------------------------------------------7Aug 03-*/
set $do_nobs do_nobs_label;
open table /if cmp($do_nobs, 'true');
set $row_class 'data';
put "<div";
trigger alt_align;
put ">" CR;
put '<table>' nl;
finish:
put '</table>' nl;
put "</div>" nl;
/*-----------------------------------------------eric-*/
/*-- if we aren't going to print the nobs label --*/
/*-- then there's no point in doing extra work. --*/
/*--------------------------------------------7Aug 03-*/
do /if cmp($do_nobs, 'true');
close;
/* print the nobs */
trigger table_nobs_label;
/* print the table */
put $$table;
unset $$table;
done;
end;
/*-------------------------------------------------------eric-*/
/*-- Count the data rows. Swap colors. --*/
/*----------------------------------------------------7Aug 03-*/
define event row;
start:
/*-----------------------------------------------eric-*/
/*-- Don't count unless we are in the data. --*/
/*--------------------------------------------7Aug 03-*/
putq '<tr>' nl;
do /if cmp(section, 'body');
eval $nobs $nobs+1 ;
done;
finish:
put '</tr>' nl;
/*-----------------------------------------------eric-*/
/*-- Swap the row style at the end of the row. --*/
/*-- That way the first row is the one we set in --*/
/*-- table start. --*/
/*--------------------------------------------7Aug 03-*/
trigger swapclass /if cmp(section, 'body');
end;
/*-------------------------------------------------------eric-*/
/*-- Print a small heading above the table. --*/
/*-- (## entries) --*/
/*----------------------------------------------------7Aug 03-*/
define event table_nobs_label;
style=nobs_label;
put '<p><h4 style="text-align: center">(' $nobs ' ';
do /if $nobs = 1;
put 'entry)' ;
else;
put 'entries)' ;
done;
put '</h4></p>';
end;
end;
/*-----------------------------------------------------------eric-*/
/*-- Most of the work is already done by the other tagsets. --*/
/*-- This one just needs to combine the byline and the nobs --*/
/*-- label into one heading. --*/
/*--------------------------------------------------------7Aug 03-*/
define tagset tagsets.by_age;
parent=tagsets.nobs_label;
mvar numfuture;
/*-------------------------------------------------------eric-*/
/*-- Add some extra comments to the doc event. --*/
/*----------------------------------------------------8Aug 03-*/
define event initialize;
set $numfuture numfuture;
eval $numfuture inputn($numfuture, '7.');
end;
/*-------------------------------------------------------eric-*/
/*-- We want to say two different things depending on the --*/
/*-- value in the byline. --*/
/*----------------------------------------------------7Aug 03-*/
define event byline;
/*-------------------------------------------------------------eric-*/
/*-- Convert numfuture to a numeric. --*/
/*----------------------------------------------------------7Aug 03-*/
eval $byval inputn(scan(value, -1, '='), '7.');
putq '<p><div class=' htmlclass ;
put 'style="text-align: center;">';
do /if $version >= $numfuture ;
put 'The Oldest';
else;
put 'Age is ' $byval ;
done;
/*---------------------------------------------------eric-*/
/*-- A newline would do, but one way or another we need --*/
/*-- to flush. Otherwise the timing goes sour. --*/
/*------------------------------------------------8Aug 03-*/
flush;
set $byline "true";
/*put '</h3> ' nl;*/
end;
/*-------------------------------------------------------eric-*/
/*-- The nobs title finishes up the paragraph started with --*/
/*-- the byline. --*/
/*----------------------------------------------------7Aug 03-*/
define event table_nobs_label;
style=nobs_label;
/*---------------------------------------------------eric-*/
/*-- If we didn't get a byline then we want to make --*/
/*-- sure the html is still well formed. --*/
/*------------------------------------------------8Aug 03-*/
put '<p><div class="byline" style="text-align: center>' /if ^$byline;
unset $byline;
put ' <span class="' htmlclass '">(' $nobs ' ';
do /if $nobs = 1;
put 'entry)' ;
else;
put 'entries)' ;
done;
put '</span></div></p>' nl;
end;
end;
run;