BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
pcfriendly
Calcite | Level 5


Hi,

I'm trying to change the format of a date/time field.

I'm going into the table, double clicking on a Cell which prompts me to accept editing access.

I then right click & go to Properties to change the Format of the field.

I saw a tutorial to do this to change a Char field to a Number but can't get this to work.

The options given are Informat which I chnage to 'MONYY' & I do the same to the Format option.

The fields turn into this '******' .

Can anyone advise what I'm doing wrong?

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions

hi ,

if you want to change the a date/time variable that you want in a mmyyyy format you must extract the date out of the variable first.

use create a new variable and edit

datepart(variable name)
and then pick the right format , i personally use mmyys7.

which give you the month and year with a slash between them

good luck.

View solution in original post

4 REPLIES 4
ChrisHemedinger
Community Manager

Is the field a datetime value? Or simply a date value?  The underlying raw value for a datetime value is a number of seconds since midnight on Jan 1, 1960.  For a date value, it's a number of days since Jan 1, 1960.  A datetime value might not be displayable (and certainly would be incorrect) in the MMYY format.  Instead, you probably want the DTMONYY5. format.

See:

Do you mind if we dance with your DATEs (or DATETIMEs)? - The SAS Dummy

Or perhaps you really do have a date value, and you haven't specified a large enough width specifier for the MMYY format.  More on formats and lengths:

Lengths and formats: the long and short of it - The SAS Dummy

Chris

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
pcfriendly
Calcite | Level 5

Hi Chris,

My mistake, the field to be changed is a Date/Time field & I want to use the feature I described above.

I'm making a mistake in the steps somewhere.

Here are some instructions I was using & adapting to a Date/ Time situation.

From this page; http://support.sas.com/kb/26/012.html

  1. Right-click on the column to be converted and select Properties
  2. Change the type to Numeric and click Yes in the warning prompt regarding precision. 
  3. Change the Group to Date. 
  4. Click Informats; the selected value under Categories should be Date. Change the informat to ANYDTDTEw. 
  5. Under Attributes, assign an overall width of 10. 
  6. Click Formats; the selected value under Categories should be Date. Change the format to MMDDYYw.d. 
  7. Under Attributes, assign an overall width of 10. 
  8. Click OK. If the conversion results are correct in the Preview Results window, click Commit changes.

  
I used the ANYDTTME format for the Informat but it still won't work...

Any suggests?

hi ,

if you want to change the a date/time variable that you want in a mmyyyy format you must extract the date out of the variable first.

use create a new variable and edit

datepart(variable name)
and then pick the right format , i personally use mmyys7.

which give you the month and year with a slash between them

good luck.

pcfriendly
Calcite | Level 5

Thanks S.boeko.

That's got it !

Cheers

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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