BookmarkSubscribeRSS Feed
BNG
Calcite | Level 5 BNG
Calcite | Level 5
Hi,
I have a question about generating a customer ID to Excel. Please take a look of the following example.

Data Customer;
Input Cust_ID $5. Deposite;
Cards;
00155 200
00166 400
;
Ods listing close;
Ods html body = “D:\MyFolder\CustList.xls”;
Proc print data = Customer noobs; Run;
Ods html close;
Ods listing;

As shown in Excel report, the Cust_ID becomes only 3 digits number (e.g. 155, 166…).
How can we avoid this format issue when exporting the dataset into Excel?

Thanks for your answer.
BNG
1 REPLY 1
Cynthia_sas
Diamond | Level 26
Hi:
Microsoft Excel treats numbers with a General format, once it gets them. Since you are using ODS HTML, my recommendation would be to:

1) switch to ODS MSOFFICE2K -- which is Microsoft "flavor" of HTML and
2) use the HTMLSTYLE attribute with an mso-number-format to tell Microsoft to use a leading zero number format.

There are examples of this method in my recent SAS Global Forum paper:
http://support.sas.com/resources/papers/proceedings11/266-2011.pdf

The leading zero example is on pages 6 and 7. You will want the HTMLSTYLE example (not the TAGATTR example -- TAGATTR is for use with TAGSETS.EXCELXP).

cynthia

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Discussion stats
  • 1 reply
  • 1288 views
  • 0 likes
  • 2 in conversation