BookmarkSubscribeRSS Feed
mikki
Calcite | Level 5


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

.

3 REPLIES 3
LinusH
Tourmaline | Level 20

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

Data never sleeps
mikki
Calcite | Level 5

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):(Column).

      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

Ksharp
Super User

data test;

     indt = '12Apr2011';

  intm = '13:20';

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

   sdttm = input(dttm,  datetime. );

format sdttm datetime.;

run;

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