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