BookmarkSubscribeRSS Feed
Inp
Obsidian | Level 7 Inp
Obsidian | Level 7
Hi
To format the data in ODS ExcelXP, we use tagattr for example
style = {tagattr='format : currency'}

My question is where can I go and find the other tagattr values to format the data and it's description. I found some of them like the one I wriiten as an example. I want to know the all available format attribute inorder to format data with leading zeros , comma etc...


Thanks

Inp
6 REPLIES 6
Cynthia_sas
SAS Super FREQ
Hi:
These are Microsoft formats. So you'd find them in the Microsoft documentation. One way I find them is to reverse engineer them -- either make a small spreadsheet and then format the number the way I want and then save the file as either HTML or XML and then open the file with Notepad. Or, I use this paper as a reference (see the table of frequently used formats on Page 7).
http://www2.sas.com/proceedings/sugi28/052-28.pdf

cynthia
deleted_user
Not applicable
Cynthia

I have reverse engineered as you said and got this as my format:


What part of this should I extract and put into my tagattr?

Thanks
Drew
Cynthia_sas
SAS Super FREQ
Hi:
That is truly the most complicated Microsoft format I have ever seen! My guess (and it's only a guess) is that it would be everything within the double quotes would move into the tagattr specification.
[pre]
"_-[$$-409]* #,##0_ ;_-[$$-409]* \-#,##0\ ;_-[$$-409]* "-"_ ;_-@_ "

either:
tagattr="_-[$$-409]* #,##0_ ;_-[$$-409]* \-#,##0\ ;_-[$$-409]* "-"_ ;_-@_ "
(without any other specification, the string is assumed to be a format)
or explicitly using Format:

tagattr="Format:_-[$$-409]* #,##0_ ;_-[$$-409]* \-#,##0\ ;_-[$$-409]* "-"_ ;_-@_ "
[/pre]

My Microsoft format explorations have not led me to anything this complicated. You may wish to work with Tech Support on this questions.

cynthia
deleted_user
Not applicable
Thanks Cynthia

I also thought that this was a little complex - I am simply trying to put the '$' and '€' formats onto my data - my 'currnecy' format is the '£' and I need to use a macro to repeat the report in all 3 currencies. Putting the string into a macro variable causes all kinds of problems because of things like the '#' character.

Any help would be appreciated.

Thanks.
Drew
Cynthia_sas
SAS Super FREQ
Hi:
I guess my thought would be to avoid a macro VARIABLE for the string and instead use macro conditional logic to build the whole procedure statement. This would mean having a macro program. Or you could work with Tech Support to see how macro quoting functions might be used effectively in this situation. I also thought there were some good suggestions here:
http://support.sas.com/forums/message.jspa?messageID=20119#20119

You could also try to simplify the format and see whether there is a simpler version of the format that would work for you. I don't really use Excel formats enough to understand how the format is being constructed from this string.

An simple example of conditionally specifying a whole procedure statement is shown below using ODS HTML, which is roughly the equivalent of what you want to do.

cynthia
[pre]
%macro dostmt(sel=X);

proc print data=sashelp.class;
title "The selection value is: &sel";
%if %upcase(&sel) = P %then %do;
var name / style(header) = {background=purple};
%end;
%else %if %upcase(&sel) = D %then %do;
var name / style(header) = {background=pink};
%end;
%else %do;
var name / style(header) = {background=cxdddddd};
%end;
var age height;
run;
%mend dostmt;

ods html file='sel_p.html' style=sasweb;
%dostmt(sel=P);
ods html close;

ods html file='sel_d.html' style=sasweb;
%dostmt(sel=D);
ods html close;

ods html file='sel_o.html' style=sasweb;
%dostmt(sel=o);
ods html close;
[/pre]
deleted_user
Not applicable
Thanks Cynthia, you've been awesome as always!

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