- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have the date1 value = 1978 i.e. all in 4 digits with informat and format of $64. I want to covert it to a numeric value with a format of year4.
First I tried:
data want;
set have;
if date2=input(date1,$64);
format date2 year4.;
run;
It doesn't work.
If I remove the format statement it keeps the value as character as the original variable.
I also tried date2=input(date1, year4.); and that doesn't work too.
Thanks.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
you could assign a length to the date2 like this
data want;
length date2 4.;
set have;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
There is no YEAR format or INFORMAT.
Years don't need formats, if the year is 1978, everyone knows what that means and you don't need to change its appearance with a format.
In your case, you want to simply convert from character to numeric
date2 = input(date1,4.);
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
you could assign a length to the date2 like this
data want;
length date2 4.;
set have;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
And will remember that.