Desktop productivity for business analysts and programmers

Change date/time DD/MM/YY to date MMYY SAS EG 4.2

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 80
Accepted Solution

Change date/time DD/MM/YY to date MMYY SAS EG 4.2


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


Accepted Solutions
Solution
‎02-06-2014 03:01 AM
Occasional Contributor
Posts: 7

Re: Change date/time DD/MM/YY to date MMYY SAS EG 4.2

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


All Replies
Community Manager
Posts: 2,693

Re: Change date/time DD/MM/YY to date MMYY SAS EG 4.2

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

Frequent Contributor
Posts: 80

Re: Change date/time DD/MM/YY to date MMYY SAS EG 4.2

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?

Solution
‎02-06-2014 03:01 AM
Occasional Contributor
Posts: 7

Re: Change date/time DD/MM/YY to date MMYY SAS EG 4.2

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.

Frequent Contributor
Posts: 80

Re: Change date/time DD/MM/YY to date MMYY SAS EG 4.2

Thanks S.boeko.

That's got it !

Cheers

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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