Search code examples
sassas-ods

SAS Conditional row highlighting with ODS and Proc Print


I want to turn the entire row red for people whose names begin with 'J'. Is this possible using proc print?

ods html file=odsout style=htmlblue ;

proc print data=sashelp.class noobs label;  
  var name age;
run;

ods html close;

Solution

  • I don't believe it's possible with PROC PRINT. PROC REPORT can generate the identical output but with the rows red, however.

    Identical:

    proc report data=sashelp.class nowd;
    columns name age;
    run;
    

    With red:

    proc report data=sashelp.class nowd;
    columns name age;
    compute name;
     if substr(name,1,1)='J' then
         call define(_row_, "style", "style=[backgroundcolor=red]");
    endcomp;
    run;
    

    I would consider it somewhat cleaner to use a style definition of course but for a one-off sort of thing this is easy.