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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

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
  • 2 replies
  • 672 views
  • 0 likes
  • 2 in conversation