BookmarkSubscribeRSS Feed
Jennys
Calcite | Level 5
Hi

I want to keep the leading 0 when I am exporting to excel through tagsets.excelxp. I try to use the format @ but it doesn´t work. Any ideas?
data ett;
text = '05566';
run;


ods path SASUSER.TEMPLAT(UPDATE) SASHELP.TMPLMST(READ) SASHELP.TEMPLAT(READ);

ods tagsets.excelxp file="/sas/sasdata/MAExports/test.xls" ;


proc print data = ett;
;
var text/style(data)={tagattr="format:@"}; ;
run;

ods tagsets.close;

ods path SASUSER.TEMPLAT(READ) SASHELP.TMPLMST(READ) SASHELP.TEMPLAT(READ);
1 REPLY 1
Eric_SAS
SAS Employee
this actually does work, although Excel still puts a flag on the value because it wants to convert it to a number.

The @ format causes the tagset to automatically set the type to String, and the format to '@'.

If you don't like the little flags, then you might want to try using a number format that will preserve the leading zeros.

format:00000

Should do the trick for this example.

Eric

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