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

I have a variable DATE that has a value of 2012-04-05. How do I convert that value into 05Apr2012?

Christos

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

Hi,

From your description, it is difficult to tell whether you want to change format for a numeric variable(dt1) or you want to make change on a character variable(dt2). Any way, the following example addressed both.

data have;

input dt1 yymmdd10. @1 dt2 $10.;

format dt1 yymmdd10.;

cards;

2012-04-05

run;

data want;

   set have;

    format dt1 date9.;

    dt2=put(input(dt2,yymmdd10.),date9.);

run;

proc print;run;

Haikuo

View solution in original post

1 REPLY 1
Haikuo
Onyx | Level 15

Hi,

From your description, it is difficult to tell whether you want to change format for a numeric variable(dt1) or you want to make change on a character variable(dt2). Any way, the following example addressed both.

data have;

input dt1 yymmdd10. @1 dt2 $10.;

format dt1 yymmdd10.;

cards;

2012-04-05

run;

data want;

   set have;

    format dt1 date9.;

    dt2=put(input(dt2,yymmdd10.),date9.);

run;

proc print;run;

Haikuo

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1 reply
  • 351 views
  • 0 likes
  • 2 in conversation