BookmarkSubscribeRSS Feed
JasonNC
Quartz | Level 8

I am expecting data as shown below

 

Dollars
 
$23,100
$5,183
$3,326
$2,070
$18
$0

 

but i am getting the data as below

 

Dollars
 
$23,100
$5,183
$3,326
$2,070
$18
$

 

when i click on the cell it shows 0 but it displays as $. what i shoul do to display as $0

 

Please see the code below and the code is customized for security purposes.

 

proc format 
picture dfmt (round)
low - < 0 = '0000,009)' (mult=.001 prefix='($')
0 - high = '000,009' (mult=.001 prefix='$');
run;

 

ods tagsets.excelxp file = "test.xls" ;
ods tagsets.ExcelXP options(embedded_titles="no" autofit_height="yes" autofit_width="yes" sheet_interval="none"
ABSOLUTE_COLUMN_WIDTH='10' sheet_name=test")

 

proc report data =test;

 

column amt;

 

define amt  / order order=data "Dollars ";

 

compute amt;
if  amt> 0 then do;
call define (_col_,"format","dfmt.");
call define (_col_,"style","style={tagattr='format:$###,###'}");
end;
else if amt < 0 then do;
call define (_col_,"format","dfmt.");
call define (_col_,"style","style={tagattr='format:$###,###'}");
end;
else do;
call define (_col_,"format","dollar4.");
call define (_col_,"style","style={tagattr='format:$#'}");
end;
endcomp;

run;

 

ods tagsets.excelxp close;

2 REPLIES 2
ballardw
Super User

If the value is missing in the SAS report then it will generally not display as 0 unless you create a format to do so OR have an option to display missing as '0' instead of '.'.

 

What does the cell look like in SAS output NOT sent to Excel?

Cynthia_sas
SAS Super FREQ
Hi: When you use TAGSETS.EXCELXP, Excel frequently does NOT use SAS formats for numeric cells or honor the number of decimal places you specify in your SAS formats. You usually need to use the TAGATTR style attribute to specify a MICROSOFT format to format the number. Refer to page 8-9 in this paper, https://support.sas.com/resources/papers/proceedings11/266-2011.pdf which shows a Microsoft format for positive, negative and zero values:

cynthia

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
  • 895 views
  • 0 likes
  • 3 in conversation