Wanted to change the SAS code to SQL, but did not know which way should I follow, but I tried with case when, it gave me error.
SAS Code:
length list_of_Fields $400.;
list_of_Fields = "";
if missing(column_a) eq 1 then do; if calc_of_count <= limit_of_Count then list_of_Fields = catx(" ;", calculation_of_columnName, "Company1"); calc_of_count + 1; end;
if missing(column_b) eq 1 then do; if calc_of_count <= limit_of_Count then list_of_Fields = catx(" ;", calculation_of_columnName, "Company2"); calc_of_count + 1; end;
if list_of_Fields eg "" then list_of_Fields = &strNone
SQL CODE:
case
when column_a is null then case when calc_of_count <= limit_of_Count then ist_of_Fields = catx(" ;", calculation_of_columnName, "Company1")
when column_b is null then case when calc_of_count <= limit_of_Count then list_of_Fields = catx(" ;", calculation_of_columnName, "Company2")
Unfortunately was not able to finish it accordingly, could you please help me to find the way?
calc_of_countand use it in your next evaluation, this is an iterative process. This is not easily done in SQL. Maybe with some recursive query, but I would rather stick to a programming language. But you are only showing a small part of code. What is it for? Maybe the overall task is easily achievable in SQL while the sub part isn't.