Just swap the MMs and the YYs. - yymms7. I've modified my code to show the same process with sorting and more months. ----------------------------- %macro one; /* -------------------------------------------- */ /* Set the macro variables. */ %let myDate1 = Sep1999; %let myDate2 = Sep2000; %let myDate3 = Dec1999; %let myDate4 = Dec2000; /* -------------------------------------------- */ /* Create the dataset with the text dates. */ data alpha; %do i = 1 %to 4; _date0 = "&&mydate&i"; output; %end; run; /* -------------------------------------------- */ /* Convert the text dates to SAS dates. */ data beta; set alpha; _date1 = input(_date0,monyy7.); run; /* -------------------------------------------- */ /* Sort on the SAS dates. */ proc sort data=beta out=gamma; by _date1; run; /* -------------------------------------------- */ /* Output */ data _null_; set gamma; put "* * * * * * * * * * * * * * * * * * * * *"; put "SAS Date: " _date1; put "Month/Year: " _date1 mmyys7.; put "Year/Month: " _date1 yymms7.; put "Name of the month: " _date1 monname9.; put "Day of the week + date: " _date1 weekdate29.; run; %mend one; %one; ---------------------------- The results are: * * * * * * * * * * * * * * * * * * * * * SAS Date: 14488 Month/Year: 09/1999 Year/Month: 1999/09 Name of the month: September Day of the week + date: Wednesday, September 1, 1999 * * * * * * * * * * * * * * * * * * * * * SAS Date: 14579 Month/Year: 12/1999 Year/Month: 1999/12 Name of the month: December Day of the week + date: Wednesday, December 1, 1999 * * * * * * * * * * * * * * * * * * * * * SAS Date: 14854 Month/Year: 09/2000 Year/Month: 2000/09 Name of the month: September Day of the week + date: Friday, September 1, 2000 * * * * * * * * * * * * * * * * * * * * * SAS Date: 14945 Month/Year: 12/2000 Year/Month: 2000/12 Name of the month: December Day of the week + date: Friday, December 1, 2000 Good luck.
... View more