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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1960 views
  • 2 likes
  • 3 in conversation