Help using Base SAS procedures

how to add % sign to output

Accepted Solution Solved
Reply
Regular Contributor
Posts: 240
Accepted Solution

how to add % sign to output

hi I have a table that divede one amt into another an it comes out with a decimal I need to add the % sign to the output

example

( sales/ inventory)as percentage_sales;

5/10. = 0.5   I need to read 50% ...thanks for your assistance in this matter


Accepted Solutions
Solution
‎08-02-2015 07:05 AM
Super User
Posts: 10,044

Re: how to add % sign to output

( sales/ inventory) as percentage_sales format=percent8.  ;

View solution in original post


All Replies
Solution
‎08-02-2015 07:05 AM
Super User
Posts: 10,044

Re: how to add % sign to output

( sales/ inventory) as percentage_sales format=percent8.  ;

Regular Contributor
Posts: 240

Re: how to add % sign to output

Xia Keshan,

It applied the symbol but when I export it was removed an reverted back to decimal ... How can I keep the symbol when it's exporting out to excel? Thanks

Super User
Super User
Posts: 7,988

Re: how to add % sign to output

Post example data in the forma of a datastep, and describe how you are exporting the data.  Generally speaking, I would be using the tagsets.excelxp and a proc report, so would just add the Excel format to the column:

http://support.sas.com/resources/papers/proceedings10/031-2010.pdf

But it depends on how your data is, and how you are exporting.

Super User
Posts: 10,044

Re: how to add % sign to output

You'd better post it at ODS and REPORT forum, It looks like ODS problem , You need some special style like : style={tagattr="format:@"}

Regular Contributor
Posts: 240

Re: how to add % sign to output

I Have a table like this

a.no,

a.market,

(a.sales/a.inventory) as percent format= percent8.,

from want a left join table b. On a.no=b.no

);run;

Proc export data = want1

outfile= sharepoint

dbms=excel replace;

newfile=yes;

run;

Regular Contributor
Posts: 240

Re: how to add % sign to output

I converted it to character it works

Super User
Super User
Posts: 7,988

Re: how to add % sign to output

Yes, that will work.  I would recommend however you 1) don't use proc export, it is a guessing procedure, i.e. it guesses what you want to do. 2) use proc report and ods tagsets.excelxp, this has a lot more functionality, and you can set formats as per the link I gave you. 

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 469 views
  • 4 likes
  • 3 in conversation