BookmarkSubscribeRSS Feed
Krisan
Calcite | Level 5

Hi every1,

I want to load the current system date and time from SAS to a field (specified in Timestamp format) in DB2. I tried using datetime format for that variable in SAS and using proc append to load data to db2 table. But i am getting format mismatch error. I cannot change the datatype of the field in DB2 as it is already existing table in PROD. Does anyone have an idea of how to achieve this?

Regards,

Krisan

5 REPLIES 5
shivas
Pyrite | Level 9

Hi,

Just try these options and check..

SASDATEFMT or DBSASTYPE...

Thanks,

Shiva

Linlin
Lapis Lazuli | Level 10

Hi Shiva,

Have not seen you on the forum for a while. Welcome back!

ArtC
Rhodochrosite | Level 12

You might also consider building a picture format.  For a datetime value you could use something like the following:

proc format;

picture dbdate

   other = '%Y-%0m-%0d:%0H:%0M:%0S' (datatype=datetime);

   run;

The %Y, %m, etc. are directives that can be used with picture formats.  There are over a dozen of them and they can be very helpful when working with date, time, and datetime values.

jthy
Calcite | Level 5

Old fashioned string handling?

data _null_;

  myDttm = datetime();

    db2ts = cats(put(datepart(myDttm), yymmdd10.), "-", tranwrd(put(timepart(myDttm), tod9.), ":", "."), ".", substr(put(timepart(myDttm), mmss15.6), 10, 6));

  put db2ts;

run;

2014-05-08-11.30.12.012000

jakarman
Barite | Level 11

As you are appending the data the existing structure and the dataset you are building should be the same.

Your error-message is telling you something has failed with that. Try to find the reason by comparing those structures.

---->-- ja karman --<-----

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
  • 5 replies
  • 5280 views
  • 0 likes
  • 6 in conversation