BookmarkSubscribeRSS Feed
xliu1
Quartz | Level 8

I need to convert a character variable which is in the format of '200905' (i.e., year and month) to a sas date format YYMMDw. which keeps the year and month

Degree_Term=input(TERM_DEG_GRANT, YYMMD7.)

 

I keep getting error message in sas log: The informat YYMMD was not found or could not be loaded.

 

Anyone can help me how to modify the code? Thanks!

3 REPLIES 3
Tom
Super User Tom
Super User

To convert text to values you need to use an INFORMAT.  Formats are for converting values to text.

There is no informat with that name.

There is on named YYMMN that will read strings with just year and month. The returned date will be the first day of the month.

ChrisNZ
Tourmaline | Level 20

The message is pretty clear:

The informat YYMMD was not found or could not be loaded.

 

This informat does not exist. You cannot make up informat names that don't exist.

 

For the string you have, the informat to use is  yymmn.  as explained above.

ballardw
Super User

@ChrisNZ wrote:

The message is pretty clear:

The informat YYMMD was not found or could not be loaded.

 

This informat does not exist. You cannot make up informat names that don't exist.

 

For the string you have, the informat to use is  yymmn.  as explained above.


Unless you write the code yourself ...

 

Not interested in writing many custom date informats though.😏

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