01-18-2015 07:04 AM
Hello, I have some problem with my SAS
What I'm trying to do, it's basically changing column value with function IF.
So i have that type of column:
What I need, is that blank cells (dots) to be filled with text 1501018, if there text in it already, it should leave it.
Could you explain me how to do that, please?
I'm trying to do it with IF function, but I have some problems with it..
It would be:
IF(/*ENDDATE = .. ?
01-18-2015 07:20 AM
Why have you chosen the if() functions specifically?
What programming environment are you using?
The coalesce() function would probably be a better fit.
01-18-2015 07:29 AM
Just first which crossed my mind - it's often in use in programming
I'm using Data Integration Studio
could you tell me which one is a proper one for me and how to fill that function?
COALESCE(expr [, expr ]...)
SELECT COALESCE ( <expression1>, <exprression2>, ...[exprN] )
01-18-2015 04:19 PM
DI Studio, which transformation?
And how does it not work?
And what kind of value is 150108 anyway? It does not make sense as a datetime value (02JAN60:17:41:48).
Do you refer to 8th ofj fanuary 2015?
01-18-2015 10:30 AM
Looks like you have a numeric variable that is formatted as a DATETIME value.
The value you want to display does not look like a date time since if it was it would be just before 9AM on Jan 18th, 1960.
You cannot put text into a numeric variable.
You could create a custom format.
proc format ;
. = '1501018'
other = [DATETIME20.];
01-18-2015 10:49 AM
*Assuming your enddate has datetime values, so covert the variable value to character and replace missing with your given character constant;
data have;/*test dataset*/
length new_enddate $19 ;
do i =1 to 5;
if i>2 then new_enddate=" ";
if missing(new_enddate) then new_enddate="1501018";
format enddate datetime18.;
01-21-2015 11:19 PM
if you are using a DI join transformation, you may need to use a "case when" statement.
case when enddate = . then 1501018 else enddate end
although you might need to sort out your formats