32 %macro _reporttcghtml(i_macroName=
43 %local l_MCoverageName;
46 %let l_MacroName=%lowcase(&i_macroName.);
47 %let l_MCoverageName=%lowcase(&i_mCoverageName.);
50 %IF (NOT %SYSFUNC(FILEEXIST(&i_mCoverageLocation./&l_MCoverageName.)) OR &l_MCoverageName=) %THEN %DO;
51 %PUT ERROR(SASUNIT): Input file with coverage data does not exist.;
54 %IF (NOT %SYSFUNC(FILEEXIST(&i_macroLocation./&l_MacroName.)) OR &l_MacroName=) %THEN %DO;
55 %PUT ERROR(SASUNIT): Input file with macro code does not exist.;
60 data WORK._MCoverage1 (where=(upcase (MacName)=
"%scan(%upcase(&l_MacroName.),1,.)"));
62 infile
"&i_mCoverageLocation./&l_MCoverageName.";
64 RecordType = input (scan (_INFILE_, 1,
' '), ??8.);
65 FirstLine = input (scan (_INFILE_, 2,
' '), ??8.);
66 LastLine = input (scan (_INFILE_, 3,
' '), ??8.);
67 MacName = scan (_INFILE_, 4,
' ');
71 proc sort data=WORK._MCoverage1 out=WORK._MCoverage3 nodupkey;
72 by Firstline RecordType LastLine;
76 data WORK._MCoverage4;
80 lag_LastLine = lag (LastLine);
81 lag_FirstLine = lag (FirstLine);
89 if (RecordType in (2)) then
do;
90 do _line_ = FirstLine to LastLine;
101 if (RecordType in (3)) then
do;
102 do nonEx = FirstLine to LastLine;
110 proc sort data=WORK._MCoverage4 out=WORK._MCoverage5 NODUPKEY;
113 proc sort data=WORK._MCoverage4 out=WORK._NonEx NODUPKEY;
118 data WORK.rowsOfInputFile;
119 length srcrow $300 nCounter 8;
120 retain srcrow
" " nCounter -1;
121 infile
"&i_macroLocation./&l_MacroName.";
124 if (index (upcase (srcrow),
"%nrstr(%MACRO )%scan(%upcase(&l_MacroName.),1,.)")) then
do;
127 if (nCounter >= 0) then
do;
137 select distinct nCounter into :MissingLines separated by
' ' from WORK.rowsOfInputFile
138 where nCounter not in (select distinct _line_ from WORK._MCoverage5 where _line_ not eq .);
146 data WORK.MCoverage ;
147 length srcrow $300 nCounter 8 srcRowCopy $2048 inExecutedBlock 8 inExecutedMBlock 8;
148 retain srcrow
" " nCounter -1 inExecutedBlock 0 inExecutedMBlock 0;
149 label srcrow=
"Macrostatements";
150 infile
"&i_macroLocation./&l_MacroName.";
152 if (index (upcase (_INFILE_),
"%nrstr(%MACRO )%scan(%upcase(&l_MacroName.),1,.)")) then
do;
153 if not(1 in (&MissingLines.)) then do;
154 inExecutedMBlock = inExecutedMBlock + 1;
158 if (nCounter >= 0) then do;
161 srcrow = cats ("", _INFILE_, "");
162 srcRowCopy = _INFILE_;
165 if (nCounter in (&MissingLines.)) then do;
166 srcrow = cats ("", _INFILE_, "");
168 _temp_row = compress (upcase (_INFILE_));
169 if (length (_temp_row) > 4) then do;
170 if ( (substr (_temp_row,1,5) = '%END;') or (substr (_temp_row,1,5) = '%END ') ) then do;
171 srcrow = cats ("", _INFILE_, "");
172 if inExecutedBlock gt 0 then do;
175 inExecutedBlock = inExecutedBlock - 1;
178 if (length (_temp_row) > 4) then do;
179 if ( (substr (_temp_row,1,6) = '%MEND;') or (substr (_temp_row,1,5) = '%MEND ') ) then do;
180 srcrow = cats ("", _INFILE_, "");
181 if inExecutedMBlock gt 0 then do;
184 inExecutedMBlock = inExecutedMBlock - 1;
189 _temp_row = compress (upcase (_INFILE_));
190 if ( (count (_temp_row,'%DO') gt 0) ) then do;
191 inExecutedBlock = inExecutedBlock + count (_temp_row,'%DO');
193 if (length (_temp_row) > 4) then do;
194 if ( (substr (_temp_row,1,5) = '%END;') or (substr (_temp_row,1,5) = '%END ') ) then do;
195 inExecutedBlock = inExecutedBlock - 1;
198 if (length (_temp_row) > 4) then do;
199 if ( (substr (_temp_row,1,6) = '%MEND;') or (substr (_temp_row,1,5) = '%MEND ') ) then do;
200 inExecutedMBlock = inExecutedMBlock - 1;
208 SET Rowsofinputfile(rename=(srcrow=srcline));
209 RETAIN inComment oneLineComment endCommentNextLine commentStartsNextLine
215 endCommentNextLine = 0;
216 commentStartsNextLine = 0;
219 IF oneLineComment = 1 THEN DO;
223 IF endCommentNextLine = 1 THEN DO;
225 endCommentNextLine =0;
227 IF commentStartsNextLine = 1 THEN DO;
229 commentStartsNextLine =0;
233 IF NOT ((index(srcline, '') > 0))THEN DO;
234 IF index(srcline, '*/') > 0 THEN DO;
235 endCommentNextLine = 1;
247 ') EQ length(compress(srcline,, 's'))-1 THEN DO;
251 ELSE IF count(srcline,'*/') gt count(srcline,'
259 update WORK.MCoverage
261 where nCounter in (select distinct nonEx from WORK._nonex where nonEx not eq .);
262 update WORK.MCoverage
264 where nCounter in ((select distinct nCounter from _commentLines where inComment eq 1 or compress(compress(srcline),"0D"x) eq ''));
270 create table rowNumbersCovered as
271 select distinct nCounter as row from WORK.MCoverage where covered EQ 1;
272 create table rowNumbersNonCovered as
273 select distinct nCounter as row from WORK.MCoverage where covered EQ 0;
274 create table rowNumbersNonCbuting as
275 select distinct nCounter as row from WORK.MCoverage where covered LE -1;
277 select count(*) into:ContributingLocCovered from rowNumbersCovered;
278 select count(*) into:ContributingLocNonCovered from rowNumbersNonCovered;
282 %let Coverage = %sysevalf (&ContributingLocCovered. / (&ContributingLocCovered. + &ContributingLocNonCovered.));
283 %let CoveragePCT = %sysfunc (putn (&Coverage., nlpct));
285 %if "&o_resVarName." NE "" %then %do;
286 %let &o_resVarName. = %sysevalf(%sysfunc (round(&Coverage.,0.01))*100);
289 data work._tcg_legend;
290 length dummy $3 Text $140;
291 dummy=" ";Text="^{unicode 25CF} ^{style tcgCoveredData &g_nls_reportAuton_018.}
";output;
292 dummy=" ";Text="^{unicode 25CF} ^{style tcgNonCoveredData &g_nls_reportAuton_019.}
";output;
293 dummy=" ";Text="^{unicode 25CF} ^{style tcgCommentData &g_nls_reportAuton_020.}
";output;
294 dummy=" ";Text="^{unicode 25CF} ^{style tcgNonContribData &g_nls_reportAuton_021.}
";output;
297 data work._tcg_report;
298 LENGTH outputRow pgmSourceColumn $2048 RowNumberOut $200;
301 outputRow = trim(srcRowCopy);
302 outputRow = tranwrd (outputRow,'^{','^[');
303 outputRow = tranwrd (outputRow,'}',']');
304 %_render_dataColumn (i_sourceColumn=RowNumber
306 ,i_columnType=tcgCommentData
307 ,o_targetColumn=RowNumberOut
309 IF covered = -1 THEN DO;
310 %_render_dataColumn (i_sourceColumn=outputRow
311 ,i_columnType=tcgCommentData
312 ,o_targetColumn=pgmSourceColumn
315 ELSE IF covered = 1 THEN DO;
316 %_render_dataColumn (i_sourceColumn=outputRow
317 ,i_columnType=tcgCoveredData
318 ,o_targetColumn=pgmSourceColumn
321 ELSE IF covered = 0 THEN DO;
322 %_render_dataColumn (i_sourceColumn=outputRow
323 ,i_columnType=tcgNonCoveredData
324 ,o_targetColumn=pgmSourceColumn
328 %_render_dataColumn (i_sourceColumn=outputRow
329 ,i_columnType=tcgNonContribData
330 ,o_targetColumn=pgmSourceColumn
338 title j=c "&g_nls_reportAuton_005.: &i_macroName
";
339 title2 "&g_nls_reportAuton_016.: &CoveragePCT.
";
341 %if (&o_html.) %then %do;
342 ods html4 file="&o_outputPath./&o_outputFile..html
"
344 headtext='<link href="tabs.css
" rel="stylesheet
" type="text/css
"/><link rel="shortcut icon
" href="./favicon.ico
" type="image/x-icon
" />'
345 metatext="http-equiv=
""Content-Style-Type
"" content=
""text/css
"" /><meta http-equiv=
""Content-Language
"" content=
""&i_language.
"" /
"
346 style=styles.SASUnit stylesheet=(URL="SAS_SASUnit.css
");
349 proc report data=work._tcg_legend nowd
350 style(report)=blindTable [borderwidth=0]
351 style(column)=blindData
352 style(lines) =blindData
353 style(header)=blindHeader;
356 compute before _page_;
357 line @1 "Color Legend:
";
362 %_reportFooter(o_html=&o_html.);
364 *** Render separation line between legend and source code ***;
365 %if (&o_html.) %then %do;
366 ods html4 text="^{RAW <hr size=
""1
"">}
";
369 proc print data=work._tcg_report noobs
370 style(report)=blindTable [borderwidth=0]
371 style(column)=blindFixedFontData
372 style(header)=blindHeader;
374 var RowNumberOut pgmSourceColumn;
377 %if (&o_html.) %then %do;
384 %mend _reporttcghtml;