BookmarkSubscribeRSS Feed
caveman529
Calcite | Level 5

Ladies and Gentlemen:

I have a variable in my dataset that is text string as below.  I hope to transfer them to SAS date.

date_have

------------

Dec-31-2008

Mar-31-2009

Mar-31-2009

Jun-30-2009

I tried the following, but it doesn't work.

date_want = input(substr(strip(date_have),1,10),MMDDYY10.);

Any suggestions?  Thanks -

4 REPLIES 4
LinusH
Tourmaline | Level 20

MMDDYY. informat requires month specified as a number - see the documentation.

You need another informat...

Data never sleeps
caveman529
Calcite | Level 5

I tried anydate11. , it seems to work for now.

Thanks-

pradeepalankar
Obsidian | Level 7

data test;

input date_have $11.;

format date_sas date9.;

date_sas=input(cats(scan(date_have,2,'-'),scan(date_have,1,'-'),scan(date_have,3,'-')),date9.);

cards;

Dec-31-2008

Mar-31-2009

Mar-31-2009

Jun-30-2009

;

run;

DR_Majeti
Quartz | Level 8

Hi,

ANYDTDTEw. 

Reads and extracts the date value from any  of the following: DATE, DATETIME, DDMMYY, JULIAN, MDYAMPM, MMDDYY, MMxYY*,

MONYY, TIME, YMDDTTM, YYMMDD, YYQ, YYxMM*, month-day-year

Try anydtdte11. in your case.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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