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

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
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

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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