The SAS Output Delivery System and reporting techniques

Maintaining formats in ods excel "percent"

Reply
Contributor
Posts: 62

Maintaining formats in ods excel "percent"

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='typeSmiley Frustratedtring'};

2.type:@

3.type:@\%

 

Thank you

Esteemed Advisor
Esteemed Advisor
Posts: 7,203

Re: Maintaining formats in ods excel "percent"

[ Edited ]

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.

Ask a Question
Discussion stats
  • 1 reply
  • 185 views
  • 0 likes
  • 2 in conversation