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

I am sending a table from EG to an excel file using ODS and proc print.

The percentage field in SAS table that is going to the Excel has numbers like below.

94.9%
24.4%
95.5%
7.1%

 

but when the SAS table gets to an excel file the format shows with two decimal point like below.

 

94.90%
24.40%
95.50%

 

I tried percent7.1, percent8.1 but neither works.

 

Below is my code. I need to know how to fix the issue so in excel the percentage field is one decimal.

 

Thanks

 

*********************************************************************************

ods listing close;

 

ods tagsets.ExcelXP style= mystyle file="excelfile.xls"

 

options(sheet_name='tab1' autofilter='all' orientation='landscape');

 

proc print data=table1 noobs split= '/'

 

style(header) = { font_style=italic font_weight = bold font_face = "calibri" font_size = 8pt just = c}

style(data) = {font_face = "Calibri" font_size = 8pt};

 

var startdt enddt client_id custid /style(header) ={foreground = white background = #ff6600};

 

var Target /style(header) = vertical_header {foreground = black background = #ccccff};

 

var Pct_Touched Pct_Enrolled pct_part /style(header) = vertical_header {foreground = black background = #ccff99};

 

format Target Pct_Touched Pct_Enrolled pct_part percent8.1;

run;

ods tagsets.ExcelXP close;

*************************************************************************************

1 ACCEPTED SOLUTION

Accepted Solutions
AndrewHowell
Moderator

The format statement won't work here - you will  need to include the Excel formatting options in the ODS style options of your variables.

 

Try:

var Target /
  style={tagattr='format:0.0%'}
  style(header) = vertical_header {foreground = black background = #ccccff}
  ;
var Pct_Touched Pct_Enrolled pct_part /
  style={tagattr='format:0.0%'}
  style(header) = vertical_header {foreground = black background = #ccff99}
  ;

 

Note you must have the "style" option before the "style(header)" option..

 

There are some excellent ODS EXCELXP whitepapers out there:

So it's worth doing a little research to get fully informed (whereas the Discussions can often be a one-off answer to a one-off question).

 

Best best is to go to Lex Jansen's website and search for ExcelXP.

 

There's a Focus Area on ExcelXP tagsets in the support.sas.com site.

 

.. and keep an eye on anything @ChrisHemedinger posts on the subject in his SasDummy blog.

 

Hope this helps.

View solution in original post

5 REPLIES 5
AndrewHowell
Moderator

The format statement won't work here - you will  need to include the Excel formatting options in the ODS style options of your variables.

 

Try:

var Target /
  style={tagattr='format:0.0%'}
  style(header) = vertical_header {foreground = black background = #ccccff}
  ;
var Pct_Touched Pct_Enrolled pct_part /
  style={tagattr='format:0.0%'}
  style(header) = vertical_header {foreground = black background = #ccff99}
  ;

 

Note you must have the "style" option before the "style(header)" option..

 

There are some excellent ODS EXCELXP whitepapers out there:

So it's worth doing a little research to get fully informed (whereas the Discussions can often be a one-off answer to a one-off question).

 

Best best is to go to Lex Jansen's website and search for ExcelXP.

 

There's a Focus Area on ExcelXP tagsets in the support.sas.com site.

 

.. and keep an eye on anything @ChrisHemedinger posts on the subject in his SasDummy blog.

 

Hope this helps.

sasmom
Fluorite | Level 6

Thanks Reeza for the link.

sasmom
Fluorite | Level 6

THANKS! That worked!

ChrisHemedinger
Community Manager

See also this video that features @Chevell_sas demoing some cool features of ODS EXCEL, including formulas and formatting.

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 6202 views
  • 2 likes
  • 4 in conversation