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

I have a simple have table. Column 1 is a string variable. 

Column1
DEC16 Estimates reflect adoption
Mar17 Estimates reflect adoption
JUN15 Estimates reflect adoption
SEP17 Estimates reflect adoption 

I would like a want table where column 2 is a date in a DATE9. format. We assume that it is the end of the month. 

Could you please help.

Column1Column 2
DEC16 Estimates reflect adoption12/31/2016
Mar17 Estimates reflect adoption3/31/2017
JUN15 Estimates reflect adoption6/30/2015
SEP17 Estimates reflect adoption 9/30/2017

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
data have;
input col $50.;
datalines;
DEC16 Estimates reflect adoption
Mar17 Estimates reflect adoption
JUN15 Estimates reflect adoption
SEP17 Estimates reflect adoption
;

data want;
set have;
date=intnx('month',input(scan(col,1),monyy5.),0,'e');
format date mmddyy10.;
run;

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20
data have;
input col $50.;
datalines;
DEC16 Estimates reflect adoption
Mar17 Estimates reflect adoption
JUN15 Estimates reflect adoption
SEP17 Estimates reflect adoption
;

data want;
set have;
date=intnx('month',input(scan(col,1),monyy5.),0,'e');
format date mmddyy10.;
run;
Astounding
PROC Star

Building upon that:

 

date=intnx('month',input(col,monyy5.),0,'e');

 

 Since the informat reads just 5 characters, the SCAN function can be eliminated.

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