I have a variable with about 5 missing dates out of 250K claims. I want to default this date to 01jan1900. When I try this
Case
when date is missing
then "01jan1900"d
else date
end
It returns as a numeric variable. When I try to put a PUT/INPUT around it to change it back to MMDDYY10. it will be blank all the way through. Any help is appreciated.
Thanks,
Andrew
If you want char
Case
when date is missing
then put( "01jan1900"d,date9.)
else date
end as var
if you want to just format to display the numeric
Case
when date is missing
then "01jan1900"d
else date
end as var format=date9.
Alright. Please clarify what do you mean by Actual date value.
SAS dates are continuous numbers(i,.e integers) starting from 0 on '01jan1960'd till date. You can use a format/in=format with put/input to either store the dates as char or read char to num respectively.
SAS variables have to be either character or numeric.
If you want it to be in DATE9. format, then it must be a numeric variable.
If you want a missing value to appear as a specific string then create a custom format that assigns such.
But the answers you have made to other posts tell me it is time for you to share actual input data and what you actually expect to be the data values. It appears that you may be confuse as this doesn't make much sense:
to change it back to MMDDYY10
Change what? Perhaps you need an explicit format assignment:
Case when missing(date) then "01jan1900"d else date end as date format=mmddyy10.
@sasspan wrote:
I have a variable with about 5 missing dates out of 250K claims. I want to default this date to 01jan1900. When I try this
Case
when date is missing
then "01jan1900"d
else date
end
It returns as a numeric variable. When I try to put a PUT/INPUT around it to change it back to MMDDYY10. it will be blank all the way through. Any help is appreciated.
Thanks,
Andrew
The CASE block is making a NEW variable, it will not retain any attributes of the original DATE variable. So if you want a specific FORMAT attached to the variable you need to tell SAS that. Same thing if you want a specific LABEL attached to this new variable.
case .... end as new_varname format=yymmdd10.
PS Try to avoid M-D-Y or D-M-Y order for dates. Which ever one you pick will confuse half of you audience. Stick with DATE9 or YYMMDD10 formats to avoid misunderstandings.
@Tom wrote:
PS Try to avoid M-D-Y or D-M-Y order for dates. Which ever one you pick will confuse half of you audience. Stick with DATE9 or YYMMDD10 formats to avoid misunderstandings.
@Tom Let's not forget the wonderful Julian date: 19262 for today! ( Really wanted one of the "devil" emoticons to go with this one).
For those Julian date impaired that date is the same as 18Sep2019 (or 18 September of any year that isn't a leap year) . Julian dates are number of day in the year preceded by a 2 or 4 digit year.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: