Hi:
When I try this code:
[pre]
data charstr;
infile datalines;
input name $ charstr $ state $;
format name charstr $8. state $2.;
return;
datalines;
Alan 0000001 OH
Bob 0000002 AL
Carl 0000003 NC
;
run;
proc contents data=charstr;
run;
ods tagsets.excelxp file='c:\temp\charstr.xls'
style=sasweb;
proc print data=charstr;
var name;
var charstr /
style(data)={tagattr="Format:text"};
var state;
run;
ods _all_ close;
[/pre]
and open the resulting Spreadsheet Markup Language file with Excel, my number is stored as text. Excel (in Office 2007) shows me that the number is stored as text with a little green triangle in the upper left hand corner of the cell. Excel is not happy about storing a number as text.
If I change the DATALINES to this:
[pre]
datalines;
Alan 0000001 OH
Bob 0000002 AL
Carl 0000003 NC
Dave Nothing GA
;
[/pre]
Then Excel does NOT put the green triangle in the cell for the string "Nothing", but still does put the green triangle (warning of number stored as text) for the first 3 observations.
If by "not work" you mean that you're getting the green triangle, this is the expected behavior. As far as I know, you have to manually "clear" that triangle by selecting a drop down box and choosing "Ignore Error" on the cells with the green triangle.
If by "not work" you mean that you're getting the numbers without leading zeroes, as numbers in the Excel worksheet, then you might consider working with Tech Support on this issue.
cynthia