BookmarkSubscribeRSS Feed
sunnyvizag
Calcite | Level 5

Hello,

I am facing challenge in getting the desired output while exporting character variable using ODS tagsets.

 

Here is the code used:

 

DATA TEST;

INPUT PERC $10;

CARDS;

2%

<0.1%

0.035%

;

RUN;

 

ODS _ALL_ CLOSE;

ODS TAGSETS.EXCELXP FILE="TEST.XLS";

PROC PRINT DATA = TEST;

    VAR PERC / STYLE= {TAGATTR= 'FORMAT:@'};

RUN;

ODS TAGSETS.EXCELXP CLOSE;

 

SAS ODS Output in Excel:

 

PERC

----

0.02%

<0.1%

0.00035%

 

I would need the output as below (Same as Dataset):

 

PERC

----

2%

<0.1%

0.035%

 

Why would ODS Excel output give 0.02% instead of 2% while it is stored as a character variable in dataset.

Can anyone help me in getting the same output in excel as in dataset?

 

Thanks in advance!

3 REPLIES 3
Cynthia_sas
SAS Super FREQ

Hi:
Microsoft has defaults and one of those defaults, typically, is to ignore some of the information you send it.

My recommendation is that, instead of formatting the field as text, you send Microsoft a Microsoft format using the correct style(data) syntax with PROC PRINT:
var PERC / STYLE(data)={TAGATTR='FORMAT:##0.###%'};

When I tried it, the numeric format worked better than using the @ to format as text.
cynthia

 

tagsets_format.png

sunnyvizag
Calcite | Level 5
Thank you so much Cynthia.. Really appreciate your help on this. I have tried, and it worked for me..
One last help, is there any format available in removing the dot in 2.% and give me 2%. This should solve my entire problem.
Thanks again!
sunnyvizag
Calcite | Level 5
Thanks much for your response.. will try with your solution today and get back to you.. thanks again..

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 982 views
  • 2 likes
  • 2 in conversation