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