DATA Step, Macro, Functions and more

Format a string 2015-07-20 07:59 so that to be able to work with time series

Reply
Occasional Contributor
Posts: 14

Format a string 2015-07-20 07:59 so that to be able to work with time series

Hi everyone,

 

First, I would like to wish everyone Happy Easter and thank you for your help.

 

Now, the question: I have a dataset from insulin's pumpa when a patient measures blood suger at very different time periods. Thus, for a TIME variable I have a string which looks like this  2015-07-20 07:59. 

 

I wonder how I can format this string to be able to work with time series?

 

Thank you in advance for any advice.

 

Regards,

 

Yuliya

Super User
Posts: 19,869

Re: Format a string 2015-07-20 07:59 so that to be able to work with time series

You need to convert your string to a SAS date for starters, the INPUT function can do this. Depending on your data it may also be possible to change it earlier, ie if you are reading it from a text file its worth fixing it in that stage. 

 

Date_var = input(string_var, anydtdtm.);
Format date_var datetime21.;
Occasional Contributor
Posts: 14

Re: Format a string 2015-07-20 07:59 so that to be able to work with time series

Hi Reeza,

 

thank you very much for your reply. Actually, I used your advice and change the format beforehand, now it is ok. But it is useful to know how INPUT works as well, I have never used it before, thank you.

 

Now I have other questions but I will post them under other title.

 

Have a nice day.

 

Regards,

 

Yuliya

Ask a Question
Discussion stats
  • 2 replies
  • 209 views
  • 1 like
  • 2 in conversation