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

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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