BookmarkSubscribeRSS Feed
milts
Pyrite | Level 9
Hi!

Is it possible that a column's style is based on the value of the other columns?

example:

a table with 5 observations, and 4 columns
i want the to change the background color of the 4th column if the difference of column3 and column2 is negative?

is that possible?

Thanks!
7 REPLIES 7
Olivier
Pyrite | Level 9
Hi !
As Cynthia would say -- just use proc Report to make your dreams come true.
Using the CALL DEFINE statement in a COMPUTE block, you can format a column using the value of other columns -- provided they are on the left of the column you want to format.
[pre]ODS HTML PATH="c:\temp" ;
PROC REPORT DATA=sashelp.class NOWD ;
COLUMNS age sex name ;
DEFINE age / DISPLAY ;
DEFINE sex / DISPLAY ;
DEFINE name / DISPLAY ;
COMPUTE name ;
IF age < 15 THEN DO ;
IF sex="F" THEN
CALL DEFINE("name","style","style={background=pink}") ;
ELSE CALL DEFINE("name","style","style={background=cyan}") ;
END ;
ELSE DO ;
IF sex="F" THEN
CALL DEFINE("name","style","style={background=red}") ;
ELSE CALL DEFINE("name","style","style={background=blue}") ;
END ;
ENDCOMP ;
RUN ;
ODS HTML CLOSE ;
milts
Pyrite | Level 9
Thanks! I'll try this one
deleted_user
Not applicable
I am using tagsets.Excelxp with several proc prints to create multiple sheets in one workbook. Can I center some column headings and right justify others within different sheets?? Thanks for the help..
Cynthia_sas
Diamond | Level 26
Hi:
You don't even need to use PROC REPORT for this one. STYLE= overrides work for PROC PRINT in a very similar fashion to the way they work in PROC REPORT.

When I run this code, I get differing column header justification on the two sheets.
cynthia
[pre]
ods tagsets.excelxp file='coljust.xls'
style=sasweb;

proc print data=sashelp.shoes(obs=2);
where region = 'Asia';
var region / style(header)={just=r};
var sales returns /style(header)={just=l};
run;

proc print data=sashelp.shoes(obs=2);
where region = 'Canada';
var product / style(header)={just=c};
var sales returns /style(header)={just=r};
run;
ods _all_ close;
[/pre]
deleted_user
Not applicable
Thanks...........I will give it a try..
deleted_user
Not applicable
Listed below is my code. The column justification is not working. Do I need somthing else?? Thanks again..

ods tagsets.Excelxp file ="P:\daily_split_dep_info_t28.xls" style = statistical
options (sheet_Name = "Split1" embedded_titles = "yes" frozen_headers = "4");
title1 '*** Deposits Charged and Paid includes the Split Deposit Information ***';
title2 '*** Deposits Paid Includes Move Ins, Switch On Cycle, and Switch Off Cycle';
run;
proc print data = work.sum_dep noobs label split = '*';
var week_day / style(header)={just=c} style(data)={font_face = arial font_weight = bold just=c};
var source_date / style={just=c};
var _freq_ / style={just=r};
var tot_dep_chg / style(header)={just=r};
var tot_dep_pd / style(header)={just=r};
var tot_dep_not_pd / style(header)={just=r};
var tot_split_dep / style(header)={just=r};
var tot_split_dep_pd / style(header)={just=r};
var tot_split_dep_not_pd / style(header)={just=r};
label week_day = 'Day of Week';
label source_date = 'Date';
label _freq_ = 'Enrollments';
label tot_dep_chg = 'Dep*Charged';
label tot_dep_pd = 'Dep*Paid';
label tot_dep_not_pd = 'Dep Not*Pd';
label tot_split_dep = 'Split*Dep';
label tot_split_dep_pd = 'Split Dep*Pd';
label tot_split_dep_not_pd = 'Split Dep*Not Pd';
where _type_ = 3;
run;
ods _all_ close;
Cynthia_sas
Diamond | Level 26
Hi:
I'm not sure what's happening. In my example, the column HEADINGS are right justified where I set Just=r and left justified where I set Just=l and center justified where I set Just=c. There's a difference between justifying the HEADER for the column (the header would be the label, like 'Date' or 'Enrollments' or 'Dep*Charged') and the data cells in a column. STYLE(HEADER) will only justify the column HEADER. That's what I see. For example, using the latest tagset for ExcelXP, I see headers justifying where I expect them to. For some of my columns, I did have to drag the edge of the column wider to make sure that I was seeing center vs left vs right justify.

Perhaps your best bet for help with this question is to open a question with Tech Support. They'll probably ask whether you have the latest version of the ExcelXP tagset. On this site, it indicates that the latest version of the tagset is from April 2008:
http://support.sas.com/rnd/base/ods/odsmarkup/ (middle of the page)

cynthia

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1740 views
  • 0 likes
  • 4 in conversation