BookmarkSubscribeRSS Feed
Virpi
Calcite | Level 5
How can I get two elements to htmlstyle definition on proc report?

like
htmlstyle="border-bottom:1px solid black; mso-number-format:'#,##0.00' " ?

to call define row-style-element..
3 REPLIES 3
Cynthia_sas
SAS Super FREQ
Hi:
Generally the CALL DEFINE statement uses the same model for syntax whether you're changing the format, the style or any of the other attributes you can change:
[pre]
call define(where,what,how);
[/pre]

for example if you want to change a column then the WHERE argument should be set to _COL_; if you want to change a named column then the WHERE argument should be set to the column name in quotes, such as 'VAR1'. Then for the WHAT argument, you would specify what you want to change: FORMAT, STYLE, etc and for the HOW argument, you specify -exactly- the syntax you need based on the WHAT argument. (Note that the WHAT and HOW arguments are always quoted, unless they are variable references; but the WHERE argument doesn't need to be quoted unless it's a specific column reference.

An example:
[pre]
COMPUTE xxxxx;
call define('salary','FORMAT','dollar12.2');
call define(_COL_,'style','style={background=blue}');
call define(_ROW_,'style','style={htmlstyle="border-bottom:1px solid black; mso-number-format:#,##0.00;"}');
ENDCOMP:
(remember that CALL DEFINE has to go in a COMPUTE block.);
[/pre]

There is this note about using HTMLSTYLE attribute in SAS 9.2:
http://support.sas.com/kb/37/079.html

It was not clear what you meant by two elements -- did you mean two report items, two report rows???? For example, if you only wanted to impact 2 report items with style overrides, you could also do this in REPORT syntax:
[pre]
proc report data=sashelp.class;
column name age height weight;
define name / order 'Name' style(column)={background=pink};
define age / display 'Age' style(header)={font_style=italic foreground=red};
*** more code ***;
[/pre]


Then you said you wanted to "call define row-style-element". "row-style-element" sounds like possibly changing something in an HTML element or tag??? If that is the case (that you want to pass an additional attribute into an HTML tag, then you might investigate the use of the TAGATTR attribute with HTML or with the PREHTML or POSTHTML style attributes. An example of some of these HTML or markup-specific style attributes can be found here:
http://support.sas.com/kb/23/380.html
http://support.sas.com/kb/24/068.html
http://support.sas.com/kb/23/668.html

cynthia
Virpi
Calcite | Level 5
Thank you Cynthia.

My problem seemed to be solved with following definition
if _break_ ne '_RBREAK_' then call define (_row_,'STYLE',"STYLE=[
htmlstyle='border-bottom:1px solid black;
mso-number-format:Standard']");

Unfuortunately that was not the case.
There is one row where border-bottom would like to be defined with 1 px. And there are column formats that sould be applied as well. There was problem with the ' and " (Quotation). The row definition overwrites the column definition but there is one column on that row where numeric format should be percent. Is there a way for conditionally have different number formats on one row that is being created on compute-block?
Cynthia_sas
SAS Super FREQ
Hi:
I'm not sure what you mean...if you mean the value for mso-number-format as a style attribute is not being applied how you want??? If you mean to conditionally change ONE cell in a report row, they you could do this...let's say this is your COLUMN statement and you want VAR1 and VAR2 to have one mso-number-format and XXX to have a different mso-number-format:
[pre]
column var1 var2 xxx;
compute xxxx;
if _break_ ne '_RBREAK_' then do;
call define('var1','style','style={........}');
call define(''var2', 'style',"style={.......}");
call define(_col_,'style',"style=(......)");
end;
endcomp;
[/pre]

Rather than using CALL DEFINE on the entire ROW, you could set attributes, including HTML style and mso-number-format separately for each report item. I don't know what the mso-number-format is for percent, which is why I didn't show anything here...that's because I find I always have to look in the Microsoft doc or reverse engineer the mso-number-format everytime I do something out of the ordinary (decimal places, currency and dates).

I'm not sure what you mean by a problem with the quotation, you can nest single quotes inside double quotes and vice versa. If you need to, you can use macro quoting function to quote or unquote or protect your values.

Also, in SAS 9.2, you can investigate the new possibilities of 'STYLE/MERGE' and 'STYLE/REPLACE' in the CALL DEFINE statement -- which can have an impact on how you specify style attributes in multiple places.
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002473624.htm
describes:

In SAS 9.2, the STYLE and STYLE/REPLACE attributes specify the style element to be used for the Output Delivery System. If a style already exists for this cell or row, these STYLE attributes tell CALL DEFINE to replace the style specified by the STYLE= value. The STYLE/MERGE attribute tells CALL DEFINE to merge the style specified by the STYLE= value with the existing style attributes that are in the same cell or row. If there is no previously existing STYLE= value to merge, STYLE/MERGE acts the same as the STYLE or STYLE/REPLACE attributes. See Using Style Elements in PROC REPORT for more details.

Restriction: This option affects only the HTML, RTF, Printer destinations.


If you continue to have issues, you might consider opening a track with Tech Support, as they could look at all your code and your data and consider your ODS destination (ODS HTML, ODS TAGSETS.EXCELXP, ODS MSOFFICE2K??) and help you come up with the best solution.

cynthia

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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