BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jdmarshg
Obsidian | Level 7

Hello everyone. 

I'm looking to get a report from a dataset to have alternating row colors. 
Which would be the best to go with ? 

HTML

msoffice2k

odsTagsetsTableEditor

 


Filename output email to="jonathan@.com"
content_type="text/html"
subject="DataSet Report" Attach="/data/ETL_work/DATA_DEV/Reports/&dataset..xls";;
ods html3 file=output style=HTMLblue;
*ods msoffice2k file=output style=HTMLblue*/
/*metatext='name="viewport" content="width="device-width"'*/
/*options(pagebreak="no" );*/
*ods tagsets.Tableeditor file=output options(format_email='yes'
pagebreak="no")
style=HTMLblue;
title1 "&dataset Report";
proc odstext;
list;
item "Profile Summary for &dataset";
item "For Date of &sysdate";
item "For All &DqzDateVerTime";
end;
run;
/*proc print data=sashelp.orsales;*/
/*var Year Product_Line Product_Group Quantity Profit;*/
/*run;*/

 

proc print data=DataReport;
run;
/*ODS tagsets.excelxp close;*/

ods _all_ close;

 

 

 

I tried using this with each of the tagsets. 

Continuing to research but wondering if I'm headed in the right direction. 

1 ACCEPTED SOLUTION

Accepted Solutions
Tim_SAS
Barite | Level 11

I think you're asking the wrong question. Alternating row colors isn't a function of the destination. You can get alternating row colors with any stylable destination. Here's how to create an HTML report with alternating row colors. If you want the report in ExcelXP format, simply substitute tagsets.excelxp for html in the ODS statement.

 

/*
 *  Assign alternating colors to the rows of a report
 */
ods html file="altcolor.html";
ods listing close;

proc report nowd data=sashelp.class
        style(header)=[background=#f0f0f0 foreground=black vjust=bottom];
    col name sex age height weight;
    define name--weight / display;
compute name;
    bg + 1;
    if mod(bg, 2) = 1 then
        call define(_row_, "style", "style={background=white}");
    else
        call define(_row_, "style", "style={background=#d1e9d1}");
endcomp;
run;

ods listing;
ods html close;

View solution in original post

2 REPLIES 2
Tim_SAS
Barite | Level 11

I think you're asking the wrong question. Alternating row colors isn't a function of the destination. You can get alternating row colors with any stylable destination. Here's how to create an HTML report with alternating row colors. If you want the report in ExcelXP format, simply substitute tagsets.excelxp for html in the ODS statement.

 

/*
 *  Assign alternating colors to the rows of a report
 */
ods html file="altcolor.html";
ods listing close;

proc report nowd data=sashelp.class
        style(header)=[background=#f0f0f0 foreground=black vjust=bottom];
    col name sex age height weight;
    define name--weight / display;
compute name;
    bg + 1;
    if mod(bg, 2) = 1 then
        call define(_row_, "style", "style={background=white}");
    else
        call define(_row_, "style", "style={background=#d1e9d1}");
endcomp;
run;

ods listing;
ods html close;
jdmarshg
Obsidian | Level 7

I just resolved. 

Thank you Tim this worked great much appreciated.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1665 views
  • 1 like
  • 2 in conversation