= SPSS If = The '''`IF`''' command conditionally assigns a value to a variable. <> ---- == Usage == {{{ if (foo=1) bar = 1. if (ltrim(rtrim(foo))="") bar = ''. }}} The parentheses are optional. When comparing string variables, string literals, and string expressions within a condition, trailing space characters are ''not'' truncated. Consider wrapping all variables and expressions with the [[SPSS/StringFunctions#RTrim|RTRIM]] function. If a string literal or string expression differs in length compared to the target variable, it is truncated or padded with space characters as needed. ---- == Data Model == The `IF` command is queued as a pending transformation. ---- == See also == [[https://www.gnu.org/software/pspp/manual/html_node/IF.html|PSPP manual for IF]] ---- CategoryRicottone