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.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

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