BookmarkSubscribeRSS Feed
erikawashere
Calcite | Level 5

I have a file that has unique identifiers that are in the format "nn-nnnn", however, everytime I export the file to CSV or XLSX using proc export, the unique identifiers for some keep converting to a date.

 

for example: The unique identifier "10-8806" keeps converting to a date "10/1/8806".  I've tried formatting the columns in excel to "Text" before exporting and that doesn't seem to work.  Is there an option I should be including in the proc export to prevent the identifier from converting to a date?

 

proc export data=defn
DBMS=XLSX REPLACE LABEL
OUTFILE="C:\Users\roster.XLSX";
SHEET="Roster";
run;

 

Thanks!

1 REPLY 1
ballardw
Super User

Blame it on Excel.

It will do strange things with values with dashes. Export to CSV and do NOT open in Excel, use something like Wordpad and you will see the values are fine. If you open in Excel and then save the csv the contents will change.

 

Changing properties in an XLSX before Export does not have any impact because the Proc Export is replacing the file. That is what the option REPLACE does.

 

You might try ODS EXCEL as the destination and use Proc Print instead of Export if you must look at it Excel.

 

data junk;
   x='10-8880';
run;

ods excel file="x:\junk.xlsx";
proc print data=junk;
run;
ods excel close;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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