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
SAS Super FREQ
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.

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
  • 2 replies
  • 1350 views
  • 0 likes
  • 2 in conversation