BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Smitha9
Fluorite | Level 6

Hi,

I have a dataset which has admissiondate: 11APR20:23:49:00 (numeric)

Another dateset which has admissiondate: 2020-04-11 23:49:00 ( character)

I want to merge these two datasets.

Can you help me in this? to change character to numeric and change the formats?

thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
ed_sas_member
Meteorite | Level 14

Hi @Smitha9 

 

You should first convert the character date in dataset2 into a valid sas datetime (numeric).

To do that you can do this;

data dataset2_bis;
	set dataset2;
	date2 =  input ("2020-04-11 23:49:00",anydtdtm.);
	format date2 datetime20.;
run;

Best,

View solution in original post

3 REPLIES 3
ed_sas_member
Meteorite | Level 14

Hi @Smitha9 

 

You should first convert the character date in dataset2 into a valid sas datetime (numeric).

To do that you can do this;

data dataset2_bis;
	set dataset2;
	date2 =  input ("2020-04-11 23:49:00",anydtdtm.);
	format date2 datetime20.;
run;

Best,

Smitha9
Fluorite | Level 6
thank you for the quick reply. I appreciate it and It worked.
Kurt_Bremser
Super User

SAS provides an informat that can read this datetime value:

data test;
instring = "2020-04-11 23:49:00";
dt = input(instring,e8601dt19.);
format dt datetime19.;
run;