BookmarkSubscribeRSS Feed
KarthikB
Calcite | Level 5

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

4 REPLIES 4
ballardw
Super User

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;

RaviKommuri
Fluorite | Level 6

Hi ballardw,

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

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

ballardw
Super User

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.

sat_lr
Calcite | Level 5

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1661 views
  • 0 likes
  • 4 in conversation