Desktop productivity for business analysts and programmers

change DATETIME var to DATE

Reply
N/A
Posts: 0

change DATETIME var to DATE

Hi,
i making web log analysis and i want to sort page views per date. As we know, the date in weblog files has this format: 02JUN2006:00:00:00. I tried to create a new variable with only the day or date (eg. 02jun or 02jun2006) by truncating or new format, but it didnt work!!

thanks for your help

Jean-Sebastien
N/A
Posts: 0

Re: change DATETIME var to DATE

Jean-Sebastien,

You can apply one of the date formats in you data or sort step:

data _null_;
d='02jun2006:00:01:00'dt;
put d= datetime. / d= datetime9. / d= dtdate9.;
run;
N/A
Posts: 0

Re: change DATETIME var to DATE

THANKS nori, it worked!
N/A
Posts: 0

Re: change DATETIME var to DATE

Another option is the datepart function which will return a date sequence.


data _null_;

datetime_var = '07jun2006:01:05:06'dt;

date_var = datepart(datetime_var);

format datetime_var datetime20. date_var date9.;

put _all_;

run;
Ask a Question
Discussion stats
  • 3 replies
  • 106 views
  • 0 likes
  • 1 in conversation