- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/... has a PDF with much information about dates.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Data X;
date1 = 12001;
Chdate = put(date1,date9.);
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
/*where initial 4 digits are year and rest months */
then what will be the format ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/... has a PDF with much information about dates.