BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sam369
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

data want;

  set have;

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

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

              year(datepart(stdt)));

run;

View solution in original post

2 REPLIES 2
art297
Opal | Level 21

data want;

  set have;

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

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

              year(datepart(stdt)));

run;

sam369
Obsidian | Level 7

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

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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