ODS and Base Reporting

Build reports by using ODS to create HTML, PDF, RTF, Excel, text reports and more!
BookmarkSubscribeRSS Feed
Imroze
Fluorite | Level 6

Hi

 

My requirement is to print percentage9.1 format in excel . If the data has 0 in decimal point then that should be ignored.

note: I have tried converting to character as well but did not work

 

Forexample:

If I am printing x variable with value as 99.0% then it should be printing 99% in excel and if it has a value of 99.1% then it should print the same.

 

What I have tried

1.style = {tagattr='type:String'};

2.type:@

3.type:@\%

 

Thank you

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

SAS doesn't work like Excel.  In SAS the whole column has to have the same format.  You could of course make the whole column text, then it can contain anything, but it wouldn't be numeric in the Excel file, i.e:

data want;
  set have;
  length pformatted $100;
  pformatted=ifc(val=0,"0",put(val,percent8,2));
run;

Pformatted would then be the variable you print out which would contain xyz% and 0's.  Thats the simplest method I can think of.  Now you may also be able to do thi using compute blocks and call style, something like:

proc report...;
  ...
  compute pval;
    if pval ne 0 then call define(_col_,'style','style=[tagattr="format:#,###.00%"]');
  endcomp;
run;

I don't have any data to test this on, but that should give some ideas.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 1 reply
  • 2145 views
  • 0 likes
  • 2 in conversation