BookmarkSubscribeRSS Feed
u52766097
Fluorite | Level 6

 How can I split these dates into mm , yy and dd for full dates and yy, and  mm for partial dates?  These dates are character values.

 

feb2010 05mar2010 05jan2010 25jul2010 
aug2010

9 REPLIES 9
u52766097
Fluorite | Level 6

I tried with ' substr ' funcation , it worked but if we have to change mm, yy and dd into numeric form and create a date format for partial date  ,how can we do that?

SASKiwi
PROC Star
data want;
  date = '05jan2010';
  date_num = input(date,date9.);
  format date_num ddmmyy10.;
run;
u52766097
Fluorite | Level 6
jan2010 05mar2010 05jan2010 25jul2010
feb2010 05mar2010 05jan2010 25jul2010
Kurt_Bremser
Super User

@u52766097 wrote:
jan2010 05mar2010 05jan2010 25jul2010
feb2010 05mar2010 05jan2010 25jul2010

And which separate numeric day, month and year values do you want to get for each of these strings?

u52766097
Fluorite | Level 6
data have;
input aestdtc : $9 aeendtc :$9. rfxstdc : $9. rfxendtc : $9.;
datalines;
11jan2010 09mar2010 05jan2010 25jul2010
21jan2010 05mar2010 05jan2010 25jul2010
jan2010 05mar2010 05jan2010 25jul2010
feb2010 05mar2010 05jan2010 25jul2010
aug2010 05mar2010 05jan2010 25jul2010
05mar2010 05jan2010 25jul2010
04jan2010 05jan2010 25jul2010
;
run;

I need all the dates in numeric form, like below-
u52766097
Fluorite | Level 6
10-01-2010 05-03-2010 05-01-2010 25-07-2010
01-01-2010 05-03-2010 05-01-2010 25-07-2010
01-2010 05-03-2010 05-01-2010 25-07-l2010
02-2010 05-03-2010 05j-01-2010 25j-07-2010
08-2010 05-03-2010 05-01-2010 25-07-2010

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 9 replies
  • 800 views
  • 0 likes
  • 3 in conversation