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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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