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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1422 views
  • 3 likes
  • 4 in conversation