Hi,
I am using VFL 4 SAS Studio. I want to create a new column using a conditional statement (see image below). I cannot write the case when although the software provides guidelines:
CASE <case-operand>
WHEN when-condition
THEN result-expression
<ELSE result-expression>
END
Can you provide an example?
Thanks,
Andreas
When i use thre Query node everythiong is fine.
I use
Case (Order_Type)
when 1 then 'X'
when 2 then 'Y'
else 'V'
end
Though in the computed columns node it does not work.
Any ideas?
It would be a good idea for you to describe the variables, conditions and needed results.
Sometimes the point and click interface is not the best way to get results and CASE when syntax can get extremely cumbersome if there are large numbers of different results and variables involved.
case categoryvariable <= variable to use in all comparisons when 'A' then 2.5 <= compare variable to 'A' and set result when 'B' then 3.7 <= compare variable to 'B' and set result when 'C' then 4.4 <= compare variable to 'C' and set result else 1 <= result for all other values of the variable end as multiplier <= end the Case expression assign result to multiplier
Hi, Thanks for your answer.
I get the following into the log so i guess case is not a valid way for the condiitonal proceccing.
ANt ideas?
Thnaks
When i use thre Query node everythiong is fine.
I use
Case (Order_Type)
when 1 then 'X'
when 2 then 'Y'
else 'V'
end
Though in the computed columns node it does not work.
Any ideas?
The computed column node sims to have an issue. I will use the Query in stead that is working properly.
Thanks!
CASE /WHEN is SQL syntax, not DATA step.
Even at that the "new column" comes after the END of the Case construct
Case when <condition> result
end as NEWCOLUMN
Data step would use IF/Then or SELECT
If variable = value then newvariable=something; ELSE if variable= othervalue then Newvariable=somethingelse; <else ...>
Or
Select (variable); when (value) NewVariable=something; when (othervalue) Newvariable=somethingelse; otherwise <what to do when none of the listed values are encountered>; end;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.