Sarah
Sarah

Reputation: 103

Inserting date variable into char variable in SQL

The bday and date variables in the work.record file are stored as date9. while the date and birth_day variables are datetime but appear to be char values; the informat and format for the orion.test variables is $10.

How do I convert my variables so that they can be inserted into the ones in orion.test?

proc sql;
    insert into orion.test  (date, birth_day)
        select r.date r.bday FROM work.record AS r;
quit;

Upvotes: 1

Views: 563

Answers (1)

Joe
Joe

Reputation: 63434

Use put to convert to character.

proc sql;
    insert into orion.test  (date, birth_day)
        select put(r.date,mmddyy10.), put(r.bday,mmddyy10.) FROM work.record AS r;
quit;

Just check that the format is appropriate (whatever format your char values in orion.test are).

Upvotes: 1

Related Questions