Does SAS have an inline if function or ternary operator?

sas

Solution

The `ifc` function (character version, `ifn` numeric) is the inline `if` function in SAS. That in SAS would be:

myString = cat("some words ",ifc(dead=1,'t','f')," some more words");

(cat family functions like cat,catx,etc. are more commonly used than the || operator in SAS).

Problem

I'm trying to concatenate a long string in SAS and it would be helpful to have an inline if function or ternary operator so that I can nest IF statements in the concatenation. I can't find mention of this in the docs. In a DATA step, I'd like to do something like: `myString = "some words " || dead == 1 ? 't' : 'f' || " some more words" ....` Basically, I'm trying to generate some seeds for demonstration Rails app, so that I can dump some SAS data into a SQLite database quickly. Is there any sort of inline if in SAS?

Original source