29 %macro _sasunit_reporttcghtml(
 
   40    %local l_MCoverageName;
 
   43    %let l_MacroName=%lowcase(&i_macroName.);
 
   44    %let l_MCoverageName=%lowcase(&i_mCoverageName.);
 
   47    %IF (NOT %SYSFUNC(FILEEXIST(&i_mCoverageLocation./&l_MCoverageName.)) OR &l_MCoverageName=) %THEN %DO;
 
   48      %PUT  ERROR: Input file with coverage data does not exist.;
 
   51    %IF (NOT %SYSFUNC(FILEEXIST(&i_macroLocation./&l_MacroName.)) OR &l_MacroName=) %THEN %DO;
 
   52      %PUT  ERROR: Input file with macro code does not exist.;
 
   57    data WORK._MCoverage1 (where=(upcase (MacName)=
"%scan(%upcase(&l_MacroName.),1,.)"));
 
   59       infile 
"&i_mCoverageLocation./&l_MCoverageName.";
 
   61       RecordType = input (scan (_INFILE_, 1, 
' '), ??8.);
 
   62       FirstLine  = input (scan (_INFILE_, 2, 
' '), ??8.);
 
   63       LastLine   = input (scan (_INFILE_, 3, 
' '), ??8.);
 
   64       MacName    = scan (_INFILE_, 4, 
' ');
 
   68    proc sort data=WORK._MCoverage1 out=WORK._MCoverage3 nodupkey;
 
   69       by Firstline RecordType LastLine;
 
   73    data WORK._MCoverage4;
 
   77       lag_LastLine = lag (LastLine);
 
   78       lag_FirstLine = lag (FirstLine);
 
   86       if (RecordType in (2)) then 
do;
 
   87          do _line_ = FirstLine to LastLine;
 
   98       if (RecordType in (3)) then 
do;
 
   99          do nonEx = FirstLine to LastLine;
 
  107    proc sort data=WORK._MCoverage4 out=WORK._MCoverage5 NODUPKEY;
 
  110    proc sort data=WORK._MCoverage4 out=WORK._NonEx NODUPKEY;
 
  115    data WORK.rowsOfInputFile;
 
  116       length srcrow $300 nCounter 8;  
 
  117       retain srcrow 
" " nCounter -1; 
 
  118       infile 
"&i_macroLocation./&l_MacroName.";
 
  121       if (index (upcase (srcrow), 
"%nrstr(%MACRO )%scan(%upcase(&l_MacroName.),1,.)")) then 
do;
 
  124       if (nCounter >= 0) then 
do;
 
  131       select distinct nCounter into :MissingLines separated by 
' ' from WORK.rowsOfInputFile 
 
  132      where nCounter not in (select distinct _line_ from WORK._MCoverage5  where _line_ not eq .);
 
  140    data WORK.MCoverage ;
 
  141       length srcrow $300 nCounter 8 srcRowCopy $2048 inExecutedBlock 8 inExecutedMBlock 8;
 
  142       retain srcrow 
" " nCounter -1 inExecutedBlock 0 inExecutedMBlock 0;
 
  143       label srcrow=
"Macrostatements"; 
 
  144       infile 
"&i_macroLocation./&l_MacroName.";
 
  146       if (index (upcase (_INFILE_), 
"%nrstr(%MACRO )%scan(%upcase(&l_MacroName.),1,.)")) then 
do;
 
  147         if not(1 in (&MissingLines.)) then do;
 
  148            inExecutedMBlock = inExecutedMBlock + 1;
 
  152       if (nCounter >= 0) then do;
 
  155       srcrow = cats ("", _INFILE_, "");
 
  156       srcRowCopy = _INFILE_;
 
  159       if (nCounter in (&MissingLines.)) then do;
 
  160          srcrow = cats ("", _INFILE_, "");
 
  162          _temp_row = compress (upcase (_INFILE_));
 
  163          if (length (_temp_row) > 4) then do;
 
  164             if ( (substr (_temp_row,1,5) = '%END;') or (substr (_temp_row,1,5) = '%END ') ) then do;
 
  165                srcrow = cats ("", _INFILE_, "");
 
  166             if inExecutedBlock gt 0 then do;
 
  169             inExecutedBlock = inExecutedBlock - 1;
 
  172          if (length (_temp_row) > 4) then do;
 
  173             if ( (substr (_temp_row,1,6) = '%MEND;') or (substr (_temp_row,1,5) = '%MEND ') ) then do;
 
  174                srcrow = cats ("", _INFILE_, "");
 
  175                if inExecutedMBlock gt 0 then do;
 
  178             inExecutedMBlock = inExecutedMBlock - 1;
 
  183         _temp_row = compress (upcase (_INFILE_));
 
  184          if ( (count (_temp_row,'%DO') gt 0) ) then do;
 
  185             inExecutedBlock = inExecutedBlock + count (_temp_row,'%DO');
 
  187        if (length (_temp_row) > 4) then do;
 
  188             if ( (substr (_temp_row,1,5) = '%END;') or (substr (_temp_row,1,5) = '%END ') ) then do;
 
  189                inExecutedBlock = inExecutedBlock - 1;
 
  192          if (length (_temp_row) > 4) then do;
 
  193             if ( (substr (_temp_row,1,6) = '%MEND;') or (substr (_temp_row,1,5) = '%MEND ') ) then do;
 
  194                inExecutedMBlock = inExecutedMBlock - 1;
 
  202      SET Rowsofinputfile(rename=(srcrow=srcline));
 
  203      RETAIN inComment oneLineComment endCommentNextLine commentStartsNextLine
 
  209         endCommentNextLine = 0;
 
  210         commentStartsNextLine = 0;
 
  213      IF oneLineComment = 1 THEN DO;
 
  217      IF endCommentNextLine = 1 THEN DO;
 
  219         endCommentNextLine =0;
 
  221      IF commentStartsNextLine = 1 THEN DO;
 
  223         commentStartsNextLine =0;
 
  227      IF NOT ((index(srcline, '') > 0))THEN DO;
 
  228         IF index(srcline, '*/') > 0 THEN DO;
 
  229            endCommentNextLine = 1;
 
  241 ') EQ length(compress(srcline,, 's'))-1 THEN DO;
 
  245        ELSE IF count(srcline,'*/') gt count(srcline,'
 
  255                 where nCounter in (select distinct nonEx from WORK._nonex where nonEx not eq .);
 
  258                 where nCounter in ((select distinct nCounter from _commentLines where inComment eq 1 or compress(compress(srcline),"0D"x) eq ''));
 
  264       create table rowNumbersCovered as
 
  265          select distinct nCounter as row from WORK.MCoverage where covered EQ  1;
 
  266       create table rowNumbersNonCovered  as
 
  267          select distinct nCounter as row from WORK.MCoverage where covered EQ  0;
 
  268       create table rowNumbersNonCbuting as
 
  269          select distinct nCounter as row from WORK.MCoverage where covered LE -1;
 
  271       select count(*) into:ContributingLocCovered from rowNumbersCovered;
 
  272       select count(*) into:ContributingLocNonCovered from rowNumbersNonCovered;
 
  276    %let Coverage = %sysevalf (&ContributingLocCovered. / (&ContributingLocCovered. + &ContributingLocNonCovered.));
 
  277    %let CoveragePCT = %sysfunc (putn (&Coverage., nlpct));
 
  279    %if "&o_resVarName." NE "" %then %do;
 
  280       %let &o_resVarName. = %sysevalf(%sysfunc (round(&Coverage.,0.01))*100);
 
  285    %LET l_linesize = %sysfunc(getoption(linesize,keyword));
 
  286    OPTIONS LINESIZE=MAX;
 
  290       LENGTH outputRow $2048;
 
  291       FILE "&o_outputPath./&o_outputFile." RECFM=P;
 
  292       SET MCoverage END=eof;
 
  293       outputRow = put(_N_,Z6.)||'  '||srcRowCopy;
 
  298          PUT '<meta http-equiv="Content-Language" content="de">';
 
  299          PUT '<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">';
 
  300          PUT '<link href="sasunit.css" rel="stylesheet" type="text/css">';
 
  301          PUT "<title>&g_nls_reportAuton_017. &i_macroName.</title>";
 
  305          PUT '<h1>'"&g_nls_reportAuton_005.: &i_macroName"'</h1>';
 
  306          PUT '<h2>'"&g_nls_reportAuton_016.: &CoveragePCT."'</h2>';
 
  307          PUT '<h3>Color Legend:</h3>';
 
  309          PUT '  <li><span style="color:
#00BE00">'"&g_nls_reportAuton_018."'</span></li>'; 
  310          PUT 
'  <li><span style="color:#FF8020">'"&g_nls_reportAuton_019."'</span></li>';
 
  311          PUT 
'  <li><span style="color:#828282">'"&g_nls_reportAuton_020."'</span></li>';
 
  312          PUT 
'  <li><span style="color:#8020FF">'"&g_nls_reportAuton_021."'</span></li>';
 
  314          PUT 
'<hr /><pre><code>';
 
  317       IF covered   = -1 THEN DO;
 
  318          PUT 
'<span style="color:#828282">' outputRow 
'</span>';
 
  320       ELSE IF covered   = 1 THEN DO;
 
  321          PUT 
'<span style="color:#00BE00">' outputRow 
'</span>';
 
  323       ELSE IF covered   = 0 THEN DO;
 
  324          PUT 
'<span style="color:#FF8020">' outputRow 
'</span>';
 
  327          PUT 
'<span style="color:#8020FF">' outputRow 
'</span>';
 
  337    OPTIONS &l_linesize.;
 
  340 %mend _sasunit_reporttcghtml;