BookmarkSubscribeRSS Feed
linc
Calcite | Level 5

I am a beginner. I am trying to used input to convert text to date, here is my function

input('Jul-17', MONYY5.)

The result is Jul01, same month but the year is wrong.

 

please help

4 REPLIES 4
Reeza
Super User

5 is the length but  text is 6 characters. Remove the -  

 

You can remove the dash with the COMPRESS() function if needed. 

 


@linc wrote:

I am a beginner. I am trying to used input to convert text to date, here is my function

input('Jul-17', MONYY5.)

The result is Jul01, same month but the year is wrong.

 

please help


 

linc
Calcite | Level 5

great thanks, the result is perfect 😄

input(compress('text',"-"),MONYY)

novinosrin
Tourmaline | Level 20
data w;
date=input('Jul-17', MONYY7.);
format date date9.;
run;
pau13rown
Lapis Lazuli | Level 10
data test;
  monthtext="January";
  month=month(input("01"||substr(monthtext,1,3)||"2000",date9.));
run;

from stackoverflow: https://stackoverflow.com/questions/9300020/sas-format-full-month-name-to-integer

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1201 views
  • 0 likes
  • 4 in conversation