Exploring, predicting and reporting with SAS Visual Analytics and SAS Visual Statistics

Custom Date Format

Reply
Occasional Contributor
Posts: 6

Custom Date Format

Dear Experts,

Could you please suggest or advice on how to do the Custom Format of a Date using the "Format" Operator option on 'New Calculated Item'

My Date from the data set is stored with the Format of "DD-MON-YYYY". The Expected Format is "Jan'19" (MMM'YY)

Thanks in advance.

Karthik

Super User
Posts: 11,144

Re: Custom Date Format

Do you really want an apostrophe in the date display?

proc format library=work;                                                                                                              

picture odddate (default=6)                                                                                                            

low-high = '%b''%y' (datatype=date);                                                                                                   

run;                                                                                                                                   

                                                                 
data _null_;                                                                                                                           

x='21Aug2014'd;                                                                                                                       

put x= odddate.;                                                                                                                      

run;

Contributor
Posts: 45

Re: Custom Date Format

Hi ballardw,

Could you please explain me this line.... I too want to learn this logic.

low-high = '%b''%y' (datatype=date);  

Super User
Posts: 11,144

Re: Custom Date Format

The low-high signals the range of values to be formatted as directed meaning the lowest value and largest value possible in SAS. A tad of overkill but since I have no idea of specific date ranges then simplest is to use all of the available values. Actually dates before some date in the year 1585 if I remember correctly won't format as a valid date. The other parts the value to display is in quotes, the %b and %y are called directives and when used with a datatype of date and for use displaying parts of the date in requested formats, look in the online help under PICTURE for formats for a complete list, %b, and lower case is needed, gets the abbreviated month name and %y gets the 2-digit year, the two single quotes are one of SAS's way of saying display one single quote as a single quote in this position would terminate the statement prematurely and result in a syntax error.

Frequent Contributor
Posts: 85

Re: Custom Date Format

Hi Karthik,

Are you using SAS VA. If yes, then look at the date data item, select it then you will see format below, from there you could select any of the available format which best satisfies your requirements. Large manipulations can also be done using those format options which doesn't exist in data source!cheers!

satlr

Ask a Question
Discussion stats
  • 4 replies
  • 466 views
  • 0 likes
  • 4 in conversation