PING  0.9
Statistical data handling and processing in production environment
sql_clause_case

Generate a quoted text that can be interpreted by the CASE clause of a SQL procedure.

%sql_clause_case(dsn, var, _case_=, when=, then=, lib=);

Arguments

  • dsn : a dataset reference;
  • var : list of fields/variables that will be added to dsn through 'ADD' clause;
  • when : list of expressions to use as conditions (WHEN) in CASE statement; it should be of same length, or length+1/-1, as then;
  • then : (option) list of expressions to use as executions (THEN values) in CASE statement; it should be of same length, or length+1/-1, as then; when of length -1, then an empty value is used;
  • lib : (option) name of the input library; by default: empty, i.e. WORK is used.

Returns

_case_ : name of the macro variable storing the SQL-like expression based on var, when, and then input parameters and that can be used as is in a CASE expression.

Examples

The simple example below:

returns .

Note

The macro will not return exactly what you want if the symbol $ appears somewhere in the when or then lists. If you need to use $ in there, you can reset the global macro variable G_PING_UNLIKELY_CHAR (see _setup_ file) to another dumb (unlikely) character of your own.

See also

%ds_select, %sql_clause_where, %sql_clause_as, %sql_clause_add, %sql_clause_by, %sql_clause_modify.