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

Hi. I currently have a dataset that contains date9. columns.

I want to convert it to yymmn6. in character. Is it do-able?

 

data date;
  input dates 8.;
  datalines;
01/02/2012
run;

i want it to be:

201202 in character.

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20
data test;
date="05dec2018"d;
format date date9.;

charDate=put(date, yymmn6.);
run;

View solution in original post

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20
data test;
date="05dec2018"d;
format date date9.;

charDate=put(date, yymmn6.);
run;
r_behata
Barite | Level 11

data have;
input dates :ddmmyy10.;
yymmn=put(dates,yymmn6.);
datalines;
01/02/2012
run;

Kurt_Bremser
Super User

Your data step creates missing values. Please test example data code before posting it here.

I guess you meant to do

data date;
input dates ddmmyy10.;
format dates date9.;
datalines;
01/02/2012
;
run;

From there you can apply the other's suggestion.

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 8594 views
  • 0 likes
  • 4 in conversation