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

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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