combine char date and char time to create numeric datetime

Reply
Occasional Contributor
Posts: 6

combine char date and char time to create numeric datetime


Hi ,

   I have to combine char date (eg  statdt = "04Apr2011") and char time(sttime = '00:00'  . ). Need to create startdate and time for calculation.

how to combine both and create numeric sas date.  and how to create DATETIME format for that.

Please help....

Thanks in advance

Mikki

.

Super User
Posts: 5,431

Re: combine char date and char time to create numeric datetime

just concatenate strings and then input using the datetime.  informat.

Data never sleeps
Occasional Contributor
Posts: 6

Re: combine char date and char time to create numeric datetime

Hi Lin,

     I tried like that already. Itried following  giving missing values.

data test;

     indt = '12Apr2011';

  intm = '13:20';

   dttm = compress(indt || intm);

   sdttm = input(dttm,  datetime. );

run;

Getting following error:

NOTE: Invalid argument to function INPUT at line 41 column 12.

indt=12Apr2011 intm=13:20 dttm=12Apr201113:20 sdttm=. _ERROR_=1 _N_=1

NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to

      missing values.

      Each place is given by: (Number of times) at (Line)Smiley SadColumn).

      1 at 41:12

Please help me ASAP  because I need to find days and hours between start date time and end date time of symptoms.

Thank you,

Mikki

Super User
Posts: 10,035

Re: combine char date and char time to create numeric datetime

data test;

     indt = '12Apr2011';

  intm = '13:20';

   dttm = compress(indt ||':'|| intm);

   sdttm = input(dttm,  datetime. );

format sdttm datetime.;

run;

Ask a Question
Discussion stats
  • 3 replies
  • 217 views
  • 0 likes
  • 3 in conversation