33 %macro _reporttcghtml(i_macroName=
44 %local l_MCoverageName;
46 %local l_MissingLines;
48 %let l_MacroName=%lowcase(&i_macroName.);
49 %let l_MCoverageName=%lowcase(&i_mCoverageName.);
52 %IF (NOT %SYSFUNC(FILEEXIST(&i_mCoverageLocation./&l_MCoverageName.)) OR &l_MCoverageName=) %THEN %DO;
53 %PUT ERROR(SASUNIT): Input file with coverage data does not exist.;
56 %IF (NOT %SYSFUNC(FILEEXIST(&i_macroLocation./&l_MacroName.)) OR &l_MacroName=) %THEN %DO;
57 %PUT ERROR(SASUNIT): Input file with macro code does not exist.;
62 data WORK._MCoverage1 (where=(upcase (MacName)=
"%scan(%upcase(&l_MacroName.),1,.)"));
64 infile
"&i_mCoverageLocation./&l_MCoverageName.";
66 RecordType = input (scan (_INFILE_, 1,
' '), ??8.);
67 FirstLine = input (scan (_INFILE_, 2,
' '), ??8.);
68 LastLine = input (scan (_INFILE_, 3,
' '), ??8.);
69 MacName = scan (_INFILE_, 4,
' ');
73 proc sort data=WORK._MCoverage1 out=WORK._MCoverage3 nodupkey;
74 by Firstline RecordType LastLine;
78 data WORK._MCoverage4;
82 lag_LastLine = lag (LastLine);
83 lag_FirstLine = lag (FirstLine);
91 if (RecordType in (2)) then
do;
92 do _line_ = FirstLine to LastLine;
103 if (RecordType in (3)) then
do;
104 do nonEx = FirstLine to LastLine;
112 proc sort data=WORK._MCoverage4 out=WORK._MCoverage5 NODUPKEY;
115 proc sort data=WORK._MCoverage4 out=WORK._NonEx NODUPKEY;
120 data WORK.rowsOfInputFile;
121 length srcrow $300 nCounter 8;
122 retain srcrow
" " nCounter -1;
123 infile
"&i_macroLocation./&l_MacroName.";
126 if (index (upcase (srcrow),
"%nrstr(%MACRO )%scan(%upcase(&l_MacroName.),1,.)")) then
do;
129 if (nCounter >= 0) then
do;
138 %let l_MissingLines = 0;
140 select distinct nCounter into :l_MissingLines separated by
' ' from WORK.rowsOfInputFile
141 where nCounter not in (select distinct _line_ from WORK._MCoverage5 where _line_ not eq .);
149 data WORK.MCoverage ;
150 length srcrow $300 nCounter 8 srcRowCopy $2048 inExecutedBlock 8 inExecutedMBlock 8;
151 retain srcrow
" " nCounter -1 inExecutedBlock 0 inExecutedMBlock 0;
152 label srcrow=
"Macrostatements";
153 infile
"&i_macroLocation./&l_MacroName.";
155 if (index (upcase (_INFILE_),
"%nrstr(%MACRO )%scan(%upcase(&l_MacroName.),1,.)")) then
do;
156 if not(1 in (&l_MissingLines.)) then do;
157 inExecutedMBlock = inExecutedMBlock + 1;
161 if (nCounter >= 0) then do;
164 srcrow = cats ("", _INFILE_, "");
165 srcRowCopy = _INFILE_;
168 if (nCounter in (&l_MissingLines.)) then do;
169 srcrow = cats ("", _INFILE_, "");
171 _temp_row = compress (upcase (_INFILE_));
172 if (length (_temp_row) > 4) then do;
173 if ( (substr (_temp_row,1,5) = '%END;') or (substr (_temp_row,1,5) = '%END ') ) then do;
174 srcrow = cats ("", _INFILE_, "");
175 if inExecutedBlock gt 0 then do;
178 inExecutedBlock = inExecutedBlock - 1;
181 if (length (_temp_row) > 4) then do;
182 if ( (substr (_temp_row,1,6) = '%MEND;') or (substr (_temp_row,1,5) = '%MEND ') ) then do;
183 srcrow = cats ("", _INFILE_, "");
184 if inExecutedMBlock gt 0 then do;
187 inExecutedMBlock = inExecutedMBlock - 1;
192 _temp_row = compress (upcase (_INFILE_));
193 if ( (count (_temp_row,'%DO') gt 0) ) then do;
194 inExecutedBlock = inExecutedBlock + count (_temp_row,'%DO');
196 if (length (_temp_row) > 4) then do;
197 if ( (substr (_temp_row,1,5) = '%END;') or (substr (_temp_row,1,5) = '%END ') ) then do;
198 inExecutedBlock = inExecutedBlock - 1;
201 if (length (_temp_row) > 4) then do;
202 if ( (substr (_temp_row,1,6) = '%MEND;') or (substr (_temp_row,1,5) = '%MEND ') ) then do;
203 inExecutedMBlock = inExecutedMBlock - 1;
211 SET Rowsofinputfile(rename=(srcrow=srcline));
212 RETAIN inComment oneLineComment endCommentNextLine commentStartsNextLine
218 endCommentNextLine = 0;
219 commentStartsNextLine = 0;
222 IF oneLineComment = 1 THEN DO;
226 IF endCommentNextLine = 1 THEN DO;
228 endCommentNextLine =0;
230 IF commentStartsNextLine = 1 THEN DO;
232 commentStartsNextLine =0;
236 IF NOT ((index(srcline, '') > 0))THEN DO;
237 IF index(srcline, '*/') > 0 THEN DO;
238 endCommentNextLine = 1;
250 ') EQ length(compress(srcline,, 's'))-1 THEN DO;
254 ELSE IF count(srcline,'*/') gt count(srcline,'
262 update WORK.MCoverage
264 where nCounter in (select distinct nonEx from WORK._nonex where nonEx not eq .);
265 update WORK.MCoverage
267 where nCounter in ((select distinct nCounter from _commentLines where inComment eq 1 or compress(compress(srcline),"0D"x) eq ''));
273 create table rowNumbersCovered as
274 select distinct nCounter as row from WORK.MCoverage where covered EQ 1;
275 create table rowNumbersNonCovered as
276 select distinct nCounter as row from WORK.MCoverage where covered EQ 0;
277 create table rowNumbersNonCbuting as
278 select distinct nCounter as row from WORK.MCoverage where covered LE -1;
280 select count(*) into:ContributingLocCovered from rowNumbersCovered;
281 select count(*) into:ContributingLocNonCovered from rowNumbersNonCovered;
285 %let Coverage = %sysevalf (&ContributingLocCovered. / (&ContributingLocCovered. + &ContributingLocNonCovered.));
286 %let CoveragePCT = %sysfunc (putn (&Coverage., nlpct));
288 %if "&o_resVarName." NE "" %then %do;
289 %let &o_resVarName. = %sysevalf(%sysfunc (round(&Coverage.,0.01))*100);
292 data work._tcg_legend;
293 length dummy $3 Text $140;
294 dummy=" ";Text="^{unicode 25CF} ^{style tcgCoveredData &g_nls_reportAuton_018.}
";output;
295 dummy=" ";Text="^{unicode 25CF} ^{style tcgNonCoveredData &g_nls_reportAuton_019.}
";output;
296 dummy=" ";Text="^{unicode 25CF} ^{style tcgCommentData &g_nls_reportAuton_020.}
";output;
297 dummy=" ";Text="^{unicode 25CF} ^{style tcgNonContribData &g_nls_reportAuton_021.}
";output;
300 data work._tcg_report;
301 LENGTH outputRow pgmSourceColumn $2048 RowNumberOut $200;
304 outputRow = trim(srcRowCopy);
305 outputRow = tranwrd (outputRow,'^{','^[');
306 outputRow = tranwrd (outputRow,'}',']');
307 %_render_dataColumn (i_sourceColumn=RowNumber
309 ,i_columnType=tcgCommentData
310 ,o_targetColumn=RowNumberOut
312 IF covered = -1 THEN DO;
313 %_render_dataColumn (i_sourceColumn=outputRow
314 ,i_columnType=tcgCommentData
315 ,o_targetColumn=pgmSourceColumn
318 ELSE IF covered = 1 THEN DO;
319 %_render_dataColumn (i_sourceColumn=outputRow
320 ,i_columnType=tcgCoveredData
321 ,o_targetColumn=pgmSourceColumn
324 ELSE IF covered = 0 THEN DO;
325 %_render_dataColumn (i_sourceColumn=outputRow
326 ,i_columnType=tcgNonCoveredData
327 ,o_targetColumn=pgmSourceColumn
331 %_render_dataColumn (i_sourceColumn=outputRow
332 ,i_columnType=tcgNonContribData
333 ,o_targetColumn=pgmSourceColumn
341 title j=c "&g_nls_reportAuton_005.: &i_macroName
";
342 title2 "&g_nls_reportAuton_016.: &CoveragePCT.
";
344 %if (&o_html.) %then %do;
345 ods html4 file="&o_outputPath./&o_outputFile..html
"
347 headtext='<link rel="shortcut icon
" href="./favicon.ico
" type="image/x-icon
" />'
348 metatext="http-equiv=
""Content-Style-Type
"" content=
""text/css
"" /><meta http-equiv=
""Content-Language
"" content=
""&i_language.
"" /
"
349 style=styles.SASUnit stylesheet=(URL="css/SAS_SASUnit.css
")
350 encoding="&g_rep_encoding.
";
353 proc report data=work._tcg_legend nowd
354 style(report)=blindTable [borderwidth=0]
355 style(column)=blindData
356 style(lines) =blindData
357 style(header)=blindHeader;
360 compute before _page_;
361 line @1 "Color Legend:
";
366 %_reportFooter(o_html=&o_html.);
368 *** Render separation line between legend and source code ***;
369 %if (&o_html.) %then %do;
370 ods html4 text="^{RAW <hr size=
""1
"">}
";
373 proc print data=work._tcg_report noobs
374 style(report)=blindTable [borderwidth=0]
375 style(column)=blindFixedFontData
376 style(header)=blindHeader;
378 var RowNumberOut pgmSourceColumn;
381 %if (&o_html.) %then %do;
388 %mend _reporttcghtml;