SASUnit Examples  Version 1.5.0
_reportcashtml.sas
Go to the documentation of this file.
1 
24 %MACRO _reportCasHTML (i_repdata =
25  ,o_html = 0
26  ,o_path =
27  ,o_file =
28  );
29 
30  %LOCAL
31  l_nls_reportcas_errors
32  l_anzScenarios
33  l_scnid
34  l_title
35  l_footnote
36 ;
37 
38  %LET l_nls_reportcas_errors = %STR(error(s));
39 
40  data work._case_report;
41  SET &i_repdata. end=eof;
42  BY scn_id cas_id;
43 
44  LENGTH
45  scn_abs_path abs_path $ 256
46  hlp $ 20
47  errcountmsg $ 50
48  LinkTitle1
49  LinkTitle2
50  LinkTitle3
51  LinkTitle4
52  LinkTitle5
53  LinkColumn1
54  LinkColumn2
55  LinkColumn3
56  LinkColumn4
57  LinkColumn5 $200
58  scnIdColumn idColumn $80
59  scnDescriptionColumn descriptionColumn $1000
60  scnProgramColumn programColumn $1000
61  scnLast_runColumn last_runColumn $1000
62  scnDurationColumn durationColumn $1000
63  resultColumn $1000;
64  ;
65  label idColumn="&g_nls_reportCas_011."
66  scnIdColumn="&g_nls_reportCas_011."
67  scnDescriptionColumn="&g_nls_reportCas_003."
68  descriptionColumn="&g_nls_reportCas_012."
69  scnProgramColumn="&g_nls_reportCas_004."
70  programColumn="&g_nls_reportCas_013."
71  scnLast_runColumn="&g_nls_reportCas_022."
72  last_runColumn="&g_nls_reportCas_014."
73  scnDurationColumn="&g_nls_reportCas_008."
74  durationColumn="&g_nls_reportCas_015."
75  resultColumn="&g_nls_reportCas_016."
76  ;
77 
78  *** initalizing variables that MAY be used in a specific assert ***;
79  if (_N_=1) then do;
80  hlp="";
81  end;
82 
83  if (first.cas_id) then do;
84  *** Columns for scenario overview ***;
85  IF scn_errorcount GT 0 THEN DO;
86  errcountmsg = '(' !! compress(put(scn_errorcount, 3.)) !! ' ' !! "&l_nls_reportcas_errors." !! ')';
87  END;
88  ELSE DO;
89  errcountmsg = '';
90  END;
91 
92  scn_abs_path = resolve ('%_abspath(&g_root,' !! trim(scn_path) !! ')');
93  scn_pgm = resolve ('%_stdpath(&g_root./saspgm/test,' !! trim(scn_abs_path) !! ')');
94  scn_duration = put (scn_end - scn_start, ??&g_nls_reportScn_013.) !! " s";
95  c_scnid = put (scn_id, z3.);
96 
97 
98  %_render_idColumn (i_sourceColumn=scn_id
99  ,i_format=z3.
100  ,o_targetColumn=ScnIdColumn
101  );
102  %_render_dataColumn (i_sourceColumn=scn_desc
103  ,o_targetColumn=scnDescriptionColumn
104  );
105  %_render_dataColumn (i_sourceColumn=scn_duration
106  ,o_targetColumn=scnDurationColumn
107  );
108 
109  *** Any destination that renders links shares this if ***;
110  %if (&o_html.) %then %do;
111  LinkTitle1 = "&g_nls_reportScn_010" !! byte(13) !! scn_abs_path;
112  LinkTitle2 = "&g_nls_reportScn_011";
113  *** HTML-links are destinations specific ***;
114  %if (&o_html.) %then %do;
115  LinkColumn1 = "file:///" !! scn_abs_path;
116  LinkColumn2 = c_scnid !! "_log.html";
117  %end;
118  %_render_dataColumn (i_sourceColumn=scn_path
119  ,i_linkColumn=LinkColumn1
120  ,i_linkTitle=LinkTitle1
121  ,o_targetColumn=scnProgramColumn
122  );
123  scnLast_runColumn = catt ('^{style [flyover="',LinkTitle2,'" url="',LinkColumn2,'"]', put (scn_start, ??&g_nls_reportScn_012.),'}'
124  ,"^{style logerrcountmsg ", errcountmsg, '}');
125  %end;
126 
127  *** Columns for test cases ***;
128  if (cas_pgm="^_") then cas_pgm="";
129  IF cas_auton = . THEN DO;
130  abs_path = resolve ('%_abspath(&g_root,' !! trim(cas_pgm) !! ')');
131  END;
132  ELSE DO;
133  abs_path = resolve ('%_abspath(&g_sasautos' !! put (cas_auton,1.) !! ',' !! trim(cas_pgm) !! ')');
134  END;
135 
136  duration = put (cas_end - cas_start, ??&g_nls_reportScn_013.) !! " s";
137  c_casid = put (cas_id, z3.);
138 
139  %_render_idColumn (i_sourceColumn=cas_id
140  ,i_format=z3.
141  ,o_targetColumn=idColumn
142  );
143  %_render_dataColumn (i_sourceColumn=duration
144  ,o_targetColumn=durationColumn
145  );
146  %_render_iconColumn (i_sourceColumn=cas_res
147  ,o_html=&o_html.
148  ,o_targetColumn=resultColumn
149  );
150  *** Any destination that renders links shares this if ***;
151  %if (&o_html.) %then %do;
152  LinkTitle3 = "&g_nls_reportCas_017 " !! c_casid;
153  LinkTitle4 = "&g_nls_reportCas_018" !! byte(13) !! abs_path;
154  LinkTitle5 = "&g_nls_reportCas_006";
155  *** HTML-links are destinations specific ***;
156  %if (&o_html.) %then %do;
157  LinkColumn3 = "cas_" !! c_scnid !! "_" !! c_casid !! ".html";
158  LinkColumn4 = "file:///" !! abs_path;
159  LinkColumn5 = c_scnid !! "_" !! c_casid !! "_log.html";
160  %end;
161 
162  %_render_dataColumn (i_sourceColumn=cas_desc
163  ,i_linkColumn=LinkColumn3
164  ,i_linkTitle=LinkTitle3
165  ,o_targetColumn=descriptionColumn
166  );
167  %_render_dataColumn (i_sourceColumn=cas_pgm
168  ,i_linkColumn=LinkColumn4
169  ,i_linkTitle=LinkTitle4
170  ,o_targetColumn=programColumn
171  );
172  %_render_dataColumn (i_sourceColumn=cas_start
173  ,i_format=&g_nls_reportCas_007.
174  ,i_linkColumn=LinkColumn5
175  ,i_linkTitle=LinkTitle5
176  ,o_targetColumn=last_runColumn
177  );
178  %end;
179  output;
180  end;
181  run;
182 
183  proc sql noprint;
184  select max (scn_id) into :l_anzScenarios from work._case_report;
185  quit;
186 
187  options nocenter;
188 
189  %let l_title=%str(&g_nls_reportCas_001 | &g_project - &g_nls_reportCas_002);
190  title j=c "&l_title.";
191 
192  %if (&o_html.) %then %do;
193  ods html4 file="&o_path./&o_file..html"
194  (TITLE="&l_title.")
195  headtext='<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />'
196  metatext="http-equiv=""Content-Style-Type"" content=""text/css"" /><meta http-equiv=""Content-Language"" content=""&i_language."" /"
197  style=styles.SASUnit stylesheet=(URL="css/SAS_SASUnit.css")
198  encoding="&g_rep_encoding.";
199  %_reportPageTopHTML(i_title = &l_title.
200  ,i_current = 3
201  )
202  %end;
203  %do l_scnid=1 %to &l_anzScenarios.;
204  data work._current_scn;
205  set work._case_report (where=(scn_id=&l_scnid.));
206  run;
207 
208  data work._current_scn_overview;
209  set work._current_scn (where=(cas_id=1));
210  length Name $20 Value $1000;
211  Name="&g_nls_reportCas_011."; Value=c_scnid;output;
212  Name="&g_nls_reportCas_003."; Value=scnDescriptionColumn;output;
213  Name="&g_nls_reportCas_004."; Value=scnProgramColumn;output;
214  Name="&g_nls_reportCas_022."; Value=scnLast_runColumn;output;
215  Name="&g_nls_reportCas_008."; Value=scnDurationColumn;output;
216  keep Name Value;
217  run;
218  *** Create specific HTML-Anchors ***;
219  %if (&o_html.) %then %do;
220  ods html4 anchor="SCN%sysfunc(putn(&l_scnid.,z3.))_";
221  %end;
222  proc print data=work._current_scn_overview noobs label
223  style(report)=blindTable [borderwidth=0]
224  style(column)=blindData
225  style(header)=blindHeader;
226  run;
227 
228  *** Supress title between testcases ***;
229  %if (&l_scnid. = 1) %then %do;
230  title;
231  %end;
232 
233  *** Show footnote only once ***;
234  %if (&l_scnid. = &l_anzScenarios.) %then %do;
235  %_reportFooter(o_html=&o_html.);
236  %end;
237 
238  proc report data=work._current_scn nowd missing
239  style(lines)=blindData
240  ;
241 
242  columns idColumn descriptionColumn programColumn last_runColumn durationColumn resultColumn;
243 
244  define idColumn / display style(Column)=rowheader;
245  define durationColumn / display style(Column)=[just=right];
246  define resultColumn / display style(Column)=[background=white];
247 
248  compute before _page_;
249  line @1 "&g_nls_reportCas_010.";
250  endcomp;
251  run;
252 
253  *** Render separation line between scenarios ***;
254  %if (&o_html. AND &l_scnid. ne &l_anzScenarios.) %then %do;
255  ods html4 text="^{RAW <hr size=""1"">}";
256  %end;
257 
258  proc delete data=work._current_scn_overview;
259  run;
260  proc delete data=work._current_scn;
261  run;
262  %end;
263 
264  %if (&o_html.) %then %do;
265  %_closeHtmlPage;
266  %end;
267 
268  proc delete data=work._case_report;
269  run;
270 
271  %*** Reset title and footnotes ***;
272  title;
273  footnote;
274 
275  options center;
276 %MEND _reportCasHTML;