@rajeshalwayswel wrote:
I found the Solution of my question: :)
data want;
input date $20.;
a1=put(input(date,anydtdte12.),yymmdd10.);
cards;
21may2019
21-may-2012
21/may/2013
21-may-2014
21-may-12
12/21/2018
run;
I would suggest that you leave the date as a date value instead of creating a text version using the Put function and assign the format to the variable:
data want;
input date $20.;
a1= input(date,anydtdte12.);
format a1 yymmdd10.;
cards;
21may2019
21-may-2012
21/may/2013
21-may-2014
21-may-12
12/21/2018
run;
Then if you need to manipulate the date such as extract values, such as the year, month, day of the year, day of the week and such then you can use an appropriate function, or increment a date, or determine the value between two dates then the functions Intnx or Intck come into play.
Also for some analysis, reporting or graphing you can change or create groups simply by changing the format
Example: (You should have the Sashelp.stocks data set available). The default format for the date variable in this data set is Date7 and represents the first stock trading day of the month.
But I want to examine the behavior of a variable by the calendar year. So
Proc means data=sashelp.stocks max min mean;
class stock date;
format date year4.;
var open;
run;
Will show the maximum, minimum and mean value of the stock opening price for each calendar year in the data for each stock.
I didn't have to add any variables to create the new group.