Help using Base SAS procedures

datetime to character date

Accepted Solution Solved
Reply
Regular Contributor
Posts: 168
Accepted Solution

datetime to character date

Hi All,

I have a variable with numeric datetime, but i need to create a new variable character variable

Have:

subj        stdt(numeric)

100          10OCT2013:12:15:32

want:

subj        stdt(numeric)                                     newvar

100          10OCT2013:12:15:32                     10 OCT 2013

My try:

newvar=scan(put(stdt,datetime20.),1,':');

I got:

10OCT2013

but i want

10 OCT 2013

Thanks

Sam


Accepted Solutions
Solution
‎10-01-2014 06:21 PM
PROC Star
Posts: 7,360

Re: datetime to character date

data want;

  set have;

  newvar=catx(' ',day(datepart(stdt)),

              upcase(put(month(datepart(stdt)),worddate3.)),

              year(datepart(stdt)));

run;

View solution in original post


All Replies
Solution
‎10-01-2014 06:21 PM
PROC Star
Posts: 7,360

Re: datetime to character date

data want;

  set have;

  newvar=catx(' ',day(datepart(stdt)),

              upcase(put(month(datepart(stdt)),worddate3.)),

              year(datepart(stdt)));

run;

Regular Contributor
Posts: 168

Re: datetime to character date

Thank you Arthur !!! that is what exactly what i am looking for. I tried datepart but i was not succeed with month section.

I got error .. thank you  today i know how to and where to use worddate3. format

Thanks

Sam

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 176 views
  • 0 likes
  • 2 in conversation