BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10

data have;

input ID DATE DATE9. TIME TIME.;

format date date9.;

format time hhmm.;

datalines;

 

12 31dec2018 12:10:02

12 11dec2018 12:11:02

;

run;

PROC EXPORT Outfile= "\\Shared\DPMS\have.xls"

DATA= have

/*label /*replace with label name*/

DBMS= EXCELCS REPLACE;

SHEET='DATA';

SERVER='saspcff';

ID DATE TIME

12 12/31/2018 1/0/1900

12 12/11/2018 1/0/1900

 

As you can see the TIME exports as 1/0/1900.  Is there a way to preserve the actual time as a time format.  The report will e dumped into another program thus the formats must remain.  In this case I want the time to retain as 10:12 and 11:12

4 REPLIES 4
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

if you use datetime32. for the format will it work

data have;
input ID DATE DATE9. TIME TIME.;
format date datetime32.;
format time hhmm.;
datalines;
 
12 31dec2018 12:10:02
12 11dec2018 12:11:02
;

run;
Ksharp
Super User

Turn it into CHARACTER variable ?

Tom
Super User Tom
Super User

Do you have to use EXCELCS engine?  Do you really need to create the old (really old) XLS format?

Why not just let SAS write the file directly using the XLSX engine?

 

PROC EXPORT Outfile= "c:\downloads\have.xlsx" dbms=xlsx replace
  data=have
;
run;

image.png

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

based on the userid I would say that they are dealing with old version of Excel along with the newer versions.

anyway it should not mater to a good programmer if the requested results are to be in versions of xls, xlsx, csv, txt or even if the file has NDX or AD1 on the end.  Data is data, and the process of providing the results are part of the business requirements gathering for the project or task that is to be preformed.  Most of the time we as the data results providers need to confirm that the managers, departments or groups that may be backing the request understand what they are asking for.  Most of the time they are just picking at the tip of the iceberg.

 

 

 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 603 views
  • 0 likes
  • 4 in conversation