想要将SAS代码更改为SQL,但不知道应该遵循哪种方法,但我尝试了case when,它给了我错误。
SAS代码:
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 = &strNoneSQL代码:
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") 不幸的是没能完成,你能帮我找一下路吗?
发布于 2019-12-04 16:57:42
您可以通过以下方式完成此操作:
CASE
WHEN (column_a is null AND calc_of_count <= limit_of_Count) THEN ist_of_Fields = CONCAT(" ;", calculation_of_columnName, "Company1")
WHEN (column_b is null AND calc_of_count <= limit_of_Count) THEN list_of_Fields = CONCAT(" ;", calculation_of_columnName, "Company2")
ELSE list_of_Fields = &strNone
END您也可以尝试使用以下格式的IF子句:
IF(condn, TRUE_STATEMENT, FALSE_STATEMENT);https://stackoverflow.com/questions/59171865
复制相似问题