BookmarkSubscribeRSS Feed
paulsparrow
Obsidian | Level 7

I have several tables where the data needs to be extracted and then parts of it updated into a SQL table.  Each source table is named with a date so I need to create that date and update the datetime field in the sql table.

What I can't seem to do is create a date in sas with a format that works when I update it in SQL.  I have tried a dozen different formats and methods to create a date field.   I keep getting the error:

ERROR: last_update, a numeric column, can only be updated with a numeric expression.

ERROR: The following columns were not found in the contributing tables: dt

Here is my update code and my latest attempt:

DATA bird.test1 ;

SET  birdout.Onboarding_060_em_20130918 ;

d = '12SEP2013'd;

  put d date.;

  dt=input(put( d  ,date7.) || ':00:00:00', datetime.);

  put dt datetime.;

RuN ;

PROC SQL ;

UPDATE 

    camp070t.mkt_onboarding_contact_history

  SET

   complete_em2 = 1 ,

  url60 = (SELECT

              url60

  FROM

  bird.test1 b

                WHERE

                  b.contact_id = mkt_onboarding_contact_history.contact_id) ,

    last_update = dt

  WHERE

     contact_id   = (SELECT

                 contact_id

     FROM

      bird.test1 b

  WHERE

   b.contact_id = mkt_onboarding_contact_history.contact_id 

                  )

  ;

QUIT ;

3 REPLIES 3
Reeza
Super User

What about the dhms formula?

dt=dhms( d, 0, 0, 0);

paulsparrow
Obsidian | Level 7

Tried that to:

d = '12SEP2013'd;

  put d date.;

  dt=dhms(d,0,0,0);

  put dt datetime.;

paulsparrow
Obsidian | Level 7

Solved the problem:  It was in my update statement:

last_update = (SELECT

              dt

  FROM

  bird.test1 b

                WHERE

                  b.contact_id = mkt_onboarding_contact_history.contact_id)

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1161 views
  • 0 likes
  • 2 in conversation