BookmarkSubscribeRSS Feed
phil27
Calcite | Level 5
Hello,
I use ods tagsets.excelxp to make xml files.

The following macro works well for integer data.

[pre]%macro pctCol(MyTable, MyVar1, MyVar2);
title2 &MyLayout2 "Pourcentages (%)";
proc tabulate data=&MyTable;
class &MyVar1 &MyVar2;
classlev &MyVar1 &MyVar2;
tables &MyVar1 all='TOTAL',&MyVar2 * colpctn='';
run;
%mend;[/pre]

But the decimal data appear with a point as decimal separator and with XML type

[pre]DATA ss:Type="String">17.69[/pre] instead of [pre]DATA ss:Type="Number">17,89[/pre] so that Excel considers the cells with decimal data as strings.

I have tried formats such as NUMx10.2, the commas appears in the cells but the XML type is still String and Excel considers the cells as strings.

I have also tried the tagattr option within the proc tabulate :

[pre]classlev &MyVar1 &MyVar2 / style={tagattr='format:##0,0'};[/pre] but the decimal separator remains a point.

I have looked for an option telling SAS to use a comma as decimal separator; I have not found.

If someone has an idea it would help me.

Thank you.
1 REPLY 1
phil27
Calcite | Level 5
I have just found a solution that works :

[pre]%macro pctCol(MyTable, MyVar1, MyVar2);
title2 &MyLayout2 "Pourcentages (%)";
proc tabulate DATA=&MyTable f=NUMx10.2 style={tagattr='type:Number Format:###0.0'};
class &MyVar1 &MyVar2;
classlev &MyVar1 &MyVar2 ;
TABLES &MyVar1 ALL='TOTAL',&MyVar2 * colpctn='' / misstext="";
run;
%mend;[/pre]

Thanks. Message was edited by: phil27

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
  • 916 views
  • 0 likes
  • 1 in conversation