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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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