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

Hello,

 

I am coding to report into an excel as below, where I want all three columns dayA dayB dayC in percent8.2 format, such as 89.28%, but why for some data,  I could only get %, but without 89.28; for some, I only get 90%, which has rounded to percent 8.0 automatically. Please help, thanks a lot!

 


Proc report data=sum contents=" " nowd split='\'
style(header)={color=black just=center background=lightgrey fontweight=bold }
style(column)={color=black just=center background=lightcyan foreground=black };
title1 j=c color=black HEIGHT=14pt BOLD "band31+";
column strat_band   dayA    dayB dayC;

define strat_band/ "Band" style=[fontstyle=Roman fontweight=bold width=2in font_size=2.2 cellwidth=2in just=center foreground=black];
define dayA/ "31+Day  " ;
define dayB/ "31+A" ;
define dayC/ "31+B" ;

%macro comp(arg);
compute &arg;
if strat_band= '190-194' then call define(_col_,'format','percent8.2');
if strat_band= '225-229' then call define(_col_,'format','percent8.2');

if strat_band= '225-229' then call define(_col_,'format','percent8.2');
if strat_band= '230-234' then call define(_col_,'format','percent8.2');
if strat_band= '235-239' then call define(_col_,'format','percent8.2');
if strat_band= '240-244' then call define(_col_,'format','percent8.2');
if strat_band= '245-249' then call define(_col_,'format','percent8.2');

endcomp;
%mend common_lines;

%comp(dayA );
%comp( dayB );
%comp( dayC);
RUN;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Try percent12.2

 

And check if Excel is helpfully adjusting your formats. Compare the value that appears to the value in the formula bar.  If it is, you'll need to use a tagattr format statement instead of SAS format. 

 

See this thread for examples, he ended up using both tagattr and increasing the width to 12.2

 

https://communities.sas.com/t5/ODS-and-Base-Reporting/Outputting-Percent-format-in-ODS-EXCEL/td-p/19...

View solution in original post

3 REPLIES 3
Reeza
Super User

Try percent12.2

 

And check if Excel is helpfully adjusting your formats. Compare the value that appears to the value in the formula bar.  If it is, you'll need to use a tagattr format statement instead of SAS format. 

 

See this thread for examples, he ended up using both tagattr and increasing the width to 12.2

 

https://communities.sas.com/t5/ODS-and-Base-Reporting/Outputting-Percent-format-in-ODS-EXCEL/td-p/19...

ballardw
Super User

You may also want to look at the values of STRAT_BAND.

 

If strat_band has any  other value then those you show in the comparison then there is no call define and you'll get a default format.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1104 views
  • 0 likes
  • 4 in conversation