BookmarkSubscribeRSS Feed
odmhx
Calcite | Level 5
I am having difficulties in right justify the numbers when I use excel tagests. The numeric column 'dischg' displays center-justified even when I added options of 'just=right'.

Here is my code:

ods tagsets.ExcelXp;
proc report data = final;
column hospital dischg;
define hospital /group;
define dischg /sum style={tagattr='format:#,##0' just=right};
run;

Can you help? Thanks!
2 REPLIES 2
Cynthia_sas
Diamond | Level 26
Hi:
When I make some fake data and run a version of your code, the numeric variables are right justified by default (see #1) and even with STYLE overrides added, the numeric variables are still right justified (see #2).

The only thing I noted was that the STYLE= override in your original code did not have the area in parentheses -- for PROC REPORT the form of the style overrride is generally:
[pre]
style(header)={....}
style(column)={....}
[/pre]

while for PROC TABULATE, the syntax is:
[pre]
style={....} or
*{s={....}} (in a TABLE statement)
[/pre]

Sometimes you can use the syntax without an area with REPORT and get OK results. But it's better to use the correct syntax so REPORT knows exactly which report element you want to change -- since the DEFINE statement could "touch" either the header cell or the data cells in the columns.

cynthia
[pre]
data final;
set sashelp.prdsale;
if country = 'GERMANY' then hospital = 'HS-1';
else if country = 'CANADA' then hospital = 'HS-2';
else hospital = 'HS-3';
dischg = int(actual /100);
othervar = int(actual);
run;

ods tagsets.ExcelXp file='c:\temp\dischg.xls' style=sasweb
options(embedded_titles='yes');

proc report data=final nowd;
title '1) default justification';
title2 'Left for CHAR var';
title3 'Right for NUM vars';
column hospital dischg othervar;
define hospital / group;
define dischg / sum;
define othervar / sum;
run;

proc report data=final nowd
style(column)={cellwidth=1in};
title '2) chg just for CHAR var';
title2 'right just for NUM vars';
title3 'bigger cells show just';
column hospital dischg othervar;
define hospital /group style(column)={just=c};
define dischg /sum style(column)={tagattr='format:#,##0' just=right};
define othervar / sum style(column)={foreground=red};
run;
ods tagsets.excelxp close;

[/pre]
odmhx
Calcite | Level 5
Thank you very much, Cynthia, for your help! I got it right now.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1954 views
  • 0 likes
  • 2 in conversation