BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
sasphd
Lapis Lazuli | Level 10

Hello 

I want to change date format from $10. to yymmn6.

thanks

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Make a new data set with an added variable. Once a variable has a type you cannot change it.

 

data want;
   set have;
   newdatevar = input(current_datevar,yymmdd10.);
   format newdatevar yymmn6.;
run;

@sasphd wrote:

Hello

my date variable is like "2023-09-18" but its format in SAS is $10.

I want to transform it to date format

thanks 


 

 

View solution in original post

4 REPLIES 4
ballardw
Super User

You will need to show some example values of your existing variable. The $10 attached to your variable means that it is a character value and so a date formatcannot be applied. You have to create a new variable this is numeric with the appropriate date value. To help do that you need to provide examples of the current variable and we can show how to make a date value.

sasphd
Lapis Lazuli | Level 10

Hello

my date variable is like "2023-09-18" but its format in SAS is $10.

I want to transform it to date format

thanks 

ballardw
Super User

Make a new data set with an added variable. Once a variable has a type you cannot change it.

 

data want;
   set have;
   newdatevar = input(current_datevar,yymmdd10.);
   format newdatevar yymmn6.;
run;

@sasphd wrote:

Hello

my date variable is like "2023-09-18" but its format in SAS is $10.

I want to transform it to date format

thanks 


 

 

Kurt_Bremser
Super User

Suppose the name of your variable is datevar.

data want;
set have (rename=(datevar=_datevar));
datevar = input(_datevar,yymmdd10.);
format datevar yymmn6.;
drop _datevar;
run;

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
  • 4 replies
  • 302 views
  • 2 likes
  • 3 in conversation