date1 =12001
Create a new variable Chdate that converts the date1 variable to a character variable that is in the format ddmonyyyy, such as 11NOV1992.
my prog :
Data X;
date1 =12001;
Chdate=put(date1,9.);
format Chdate ddmonyyyy. ;
run;
output
date1 Chdate
12001 12001
Chdate should be in format ddmonyy.
https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/... has a PDF with much information about dates.
Data X;
date1 = 12001;
Chdate = put(date1,date9.);
run;
@librasonali wrote:
if date1 =201411
/*where initial 4 digits are year and rest months */
then what will be the format ?
If that is stored as a number, you need to first convert it to a SAS date:
date1 = input(put(date1,z6.),yymmn6.);
for the DATE9. format to work. You will see that the resulting date is the first of the month.
https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/... has a PDF with much information about dates.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.