BookmarkSubscribeRSS Feed
saslackey
Calcite | Level 5
hi, Im unable to create tables without the plain black ,white grey colors that are the default colors. Could someone help me on how i can derive background color of yellow in the coloumn names and background color of blue in the rows of my table. here is my code for the ODS


FILENAME odsout "P:\SASData\ANU\";
goptions reset=all HBY=2 ftext="helvetica" device=gif733;
pattern1 value=solid;
OPTIONS ORIENTATION=portrait;


ODS HTML newfile=bygroup Path=odsout BODY="R1.html";
ODS PDF BODY="P:\SASData\R1.PDF" style=concepts.table1

fontscale=100;* startpage=never;



Proc Report nowd data=LATEST;
*By year;
*format year yearfmt.;
TITLE1 ' Texas Region 1 - Panhandle and South Plains Trends: in Size and Location Adjusted Weighted Average';
title2 ' Index Price of Rural Land, 1966-2010';
footnote1 j=l 'Note:Real values are in 1966 dollars';
footnote2 j=l 'Source: Real Estate Center at Texas A & M Univeristy';


col ((' ' Year))

('Nominal'
(' ' PRICE)
(' ' YEARTOYEARPERCENTCHANGE)
(' ' ANNUALCOMPOUNG5YEARGROWTHRATE))

('Real'
(' ' Deflated_PRICE)
(' ' YEARTOYEARPERCENTCHANGE2)
(' ' ANNUALCOMPOUNG5YEARGROWTHRATE2))

((' ' SALES))

((' ' SIZE));



Define YEAR / "Year" F=5.0 center group style={cellwidth=75};
Define PRICE / "Weighted Average Index Price Per Acre" center F=COMMA10. style={cellwidth=100};
Define YEARTOYEARPERCENTCHANGE / "Year-to-Year Percentage Change" center F=COMMA8.0 style={cellwidth=100};
Define ANNUALCOMPOUNG5YEARGROWTHRATE / 'Annual Compound 5 Year Growth Rate' center F=COMMA8.0 style={cellwidth=100};
Define DEFLATED_PRICE / "Deflated* Weighted Average Index Price Per Acre" center F=COMMA10. style={cellwidth=100};
Define YEARTOYEARPERCENTCHANGE2 / "Year-to-Year Percentage Change" center F=COMMA8.0 style={cellwidth=100};
Define ANNUALCOMPOUNG5YEARGROWTHRATE2 / 'Annual Compound 5 Year Growth Rate' center F=COMMA8.0 style={cellwidth=100};
Define SALES / "Volume of Sales" F=COMMA8.0 center style={cellwidth=100};
Define SIZE / "Median Tract Size(Acres)" center Format=COMMA12.0;
run;

ods html close;
ods listing;
4 REPLIES 4
Cynthia_sas
SAS Super FREQ
Hi:
I see a few problems with your code:
1) you have an ODS HTML statement and an ODS PDF statement at the top of the program, but you ONLY have an ODS HTML CLOSE at the bottom of the program. This is likely to cause issues.

2) I see that in your ODS PDF invocation, you have: style=concepts.table1 and without seeing the style template code that's inside the concepts.table1 style template definition, it's sort of hard to figure out what's going on.

3) I don't actually see that you are doing any graphics in this program (which would be the reason for posting in the SAS/GRAPH forum -- normally, I'd expect to see this question posted in the regular ODS and Report Procedures forum). also, I do not understand why you are setting GOPTIONS and HBY or FTEXT or DEVICE= -- but perhaps you didn't post your whole program. With SAS Title and Footnote statements in regular ODS, you can change the font of the Title and Footnote directly in the TITLE and FOOTNOTE statements (as I show with F= in the code below).

4) Nobody much uses FONTSCALE anymore -- it was really useful for HTML destinations, where the fonts were specified as relative numbers and you could specify the font scale as an option. Mostly, this option has waned in popularity, as viewers (like Acrobat Reader, and IE or Firefox or Word) all have their own way to do "zooming" of the entire document.

As for your question about not getting the colors you expect, let's take the style template out of the mix and try something else. See the program below that uses SASHELP.SHOES. Note how I make the column headers YELLOW. Note also how I make the cells for selected years PURPLE and then note how I make one entire row all PINK and another entire row a light BLUE.

If you run this code and get the same results, then I would suggest that the reason your program is not working is that there's something wrong with concepts.table1 style template (if you have specified YELLOW and BLUE as colors in the style template). Generally speaking, the style template will only provide background and foreground colors for header cells and data cells...all the header cells the same and all the data cells the same -- to do things like I show below -- making one row one color and another row a different color, you will need to use CALL DEFINE within PROC REPORT to change the style attributes of a ROW or COLUMN. A style template, in the simplest form, would not be able to make the YEAR cells purple, and the PRICE cells gray. So I will admit to a certain amount of curiousity about what's in your custom style template.

cynthia
[pre]
OPTIONS ORIENTATION=portrait;
** make some fake data using sashelp.shoes;
data latest;
set sashelp.shoes;
where region in ('Asia', 'Canada', 'Pacific', 'Western Europe');
if region = 'Asia' then Year = 2010;
else if region = 'Canada' then Year = 2009;
else if region = 'Pacific' then Year = 2008;
else if region = 'Western Europe' then Year = 2007;
price = (inventory-returns) / 100;
yeartoyearpercentchange = 5.00;
annualcompoung5yeargrowthrate = 1.0;
deflated_price = price * .8;
yeartoyearpercentchange2 = 3.00;
ANNUALCOMPOUNG5YEARGROWTHRATE2 = 1.0;
size = returns / 10;
run;

ods listing close;
** use sasweb style which has a white backgroun for HTML;
ODS HTML Path='c:\temp\' (url=none) BODY="R1.html" style=sasweb;
ODS PDF BODY="c:\temp\R1.PDF";

Proc Report nowd data=LATEST
style(header)={background=yellow foreground=black};
TITLE1 f="Helvetica" h=14pt ' Texas Region 1 - Panhandle and South Plains Trends: in Size and Location Adjusted Weighted Average';
title2 f="Helvetica" h=14pt ' Index Price of Rural Land, 1966-2010';
footnote1 f="Helvetica" h=10pt j=l 'Note:Real values are in 1966 dollars';
footnote2 f="Helvetica" h=10pt j=l 'Source: Real Estate Center at Texas A & M University';


col ((' ' Year))
('Nominal'
(' ' PRICE)
(' ' YEARTOYEARPERCENTCHANGE)
(' ' ANNUALCOMPOUNG5YEARGROWTHRATE))
('Real'
(' ' Deflated_PRICE)
(' ' YEARTOYEARPERCENTCHANGE2)
(' ' ANNUALCOMPOUNG5YEARGROWTHRATE2))
((' ' SALES))
((' ' SIZE));

Define YEAR / "Year" F=5.0 center group style={cellwidth=75}
style(column)={background=cxCC99FF};
Define PRICE / "Weighted Average Index Price Per Acre" center
F=COMMA10. style={cellwidth=100}
style(column)={background=cxdddddd};
Define YEARTOYEARPERCENTCHANGE / "Year-to-Year Percentage Change" center F=COMMA8.0 style={cellwidth=100};
Define ANNUALCOMPOUNG5YEARGROWTHRATE / 'Annual Compound 5 Year Growth Rate' center F=COMMA8.0 style={cellwidth=100};
Define DEFLATED_PRICE / "Deflated* Weighted Average Index Price Per Acre" center F=COMMA10. style={cellwidth=100};
Define YEARTOYEARPERCENTCHANGE2 / "Year-to-Year Percentage Change" center F=COMMA8.0 style={cellwidth=100};
Define ANNUALCOMPOUNG5YEARGROWTHRATE2 / 'Annual Compound 5 Year Growth Rate' center F=COMMA8.0 style={cellwidth=100};
Define SALES / "Volume of Sales" F=COMMA8.0 center style={cellwidth=100};
Define SIZE / "Median Tract Size(Acres)" center Format=COMMA12.0;
compute year;
if year = 2007 then
call define(_ROW_,'style','style={background=cxCCFFFF}');
endcomp;
compute ANNUALCOMPOUNG5YEARGROWTHRATE;
if ANNUALCOMPOUNG5YEARGROWTHRATE.sum = 14 then
call define(_ROW_,'style','style={background=pink}');
endcomp;
run;

ods _all_ close;
ods listing;

[/pre]
saslackey
Calcite | Level 5
hey,

that was immensely helpful. I was able to implement the colors. Sorry about posting it in the wrong forum . And yes i dint post the whole program. It is quite long. But thanks again. it was jus the small syntax with the background= color tht i was looking for. I am finding it hard to search for syntax help in SAS. hence i posted it here to get help from people like you. I immensely appreciate it . thank you so much!
saslackey
Calcite | Level 5
Anoher question i have is would i be able to have different colors for the coloumn names as well? like in your code as i had aksed for its all yellow. Could i have 2 or 3 different colored coloumns as well?
Cynthia_sas
SAS Super FREQ
Yes, just like I use style(column) to change the background color of the data cells for PRICE, I could use style(header) to change the background color of the header cells for PRICE:
[pre]
Define PRICE / "Weighted Average Index Price Per Acre" center
F=COMMA10. style(header)={background=pink}
style(column)={background=cxdddddd};
[/pre]

Also, sorry i didn't catch it before -- PROC TABULATE uses the STYLE={background=cxdddddd} type of syntax (without an area --HEADER or COLUMN), but PROC REPORT really, really is happier when you specify the report area in the DEFINE Statement.

But, that's not why I got ride of your style={cellwidth=100} in the above DEFINE statement for PRICE. Also, just as a side note...100 by default means 100 pixels...but PDF is using PTs (points) mostly. So, I'd probably try not to force PDF to make the conversion from PIXELS to POINTS. If you want the HTML output to be approximately the same width as the PDF output, I'd tend to use the OUTPUTWIDTH style attribute on a STYLE(REPORT) override and get rid of all the CELLWIDTH attribute overrides entirely.

cynthia

Change to PROC REPORT statement (do not mix OUTPUTWIDTH and CELLWIDTH -- if you use this technique, get rid of all CELLWIDTH attributes):
[pre]
proc report nowd data=latest
style(report)={outputwidth=7.5in}
style(header)={background=yellow foreground=black};
[/pre]

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 4 replies
  • 1639 views
  • 0 likes
  • 2 in conversation