Concatenates character or numeric values by using a delimiter to separate items and by adding quotation marks to strings that contain the delimiter.
Category: | Character |
specifies a character constant, variable, or expression in which each non-blank character modifies the action of the CATQ function. Blanks are ignored. You can use the following characters as modifiers:
uses single quotation marks when CATQ adds quotation marks to a string.
uses double quotation marks when CATQ adds quotation marks to a string.
adds quotation marks to all of the item arguments.
adds quotation marks to item arguments that have leading or trailing blanks that are not removed by the S or T modifiers.
uses a comma as a delimiter.
indicates that you have specified the delimiter argument.
uses a horizontal tab as the delimiter.
inserts a delimiter for every item argument after the first. If you do not use the M modifier, then CATQ does not insert delimiters for item arguments that have a length of zero after processing that is specified by other modifiers. The M modifier can cause delimiters to appear at the beginning or end of the result and can cause multiple consecutive delimiters to appear in the result.
converts item arguments to name literals when the value does not conform to the usual syntactic conventions for a SAS name. A name literal is a string in quotation marks that is followed by the letter “n” without any intervening blanks. To use name literals in SAS statements, you must specify the SAS option, VALIDVARNAME=ANY.
adds quotation marks to item arguments that already contain quotation marks.
strips leading and trailing blanks from subsequently processed arguments:
converts item arguments to hexadecimal literals when the value contains nonprintable characters.
Tips | If modifier is a constant, enclose it in quotation marks. You can also express modifier as a variable name or an expression. |
The A, B, N, Q, S, T, and X modifiers operate internally to the CATQ function. If an item argument is a variable, then the value of that variable is not changed by CATQ unless the result is assigned to that variable. |
specifies a constant, variable, or expression, either character or numeric. If item is numeric, then its value is converted to a character string by using the BESTw. format. In this case, leading blanks are removed and SAS does not write a note to the log.
options ls=110; data _null_; result1=CATQ(' ', 'noblanks', 'one blank', 12345, ' lots of blanks '); result2=CATQ('CS', 'Period (.) ', 'Ampersand (&) ', 'Comma (,) ', 'Double quotation marks (") ', ' Leading Blanks'); result3=CATQ('BCQT', 'Period (.) ', 'Ampersand (&) ', 'Comma (,) ', 'Double quotation marks (") ', ' Leading Blanks'); result4=CATQ('ADT', '#=#', 'Period (.) ', 'Ampersand (&) ', 'Comma (,) ', 'Double quotation marks (") ', ' Leading Blanks'); result5=CATQ('N', 'ABC_123 ', '123 ', 'ABC 123'); put (result1-result5) (=/); run;
result1=noblanks "one blank" 12345 " lots of blanks " result2=Period (.),Ampersand (&),"Comma (,)",Double quotation marks ("),Leading Blanks result3=Period (.),Ampersand (&),"Comma (,)",'Double quotation marks (")'," Leading Blanks" result4="Period (.)"#=#'Ampersand (&)'#=#"Comma (,)"#=#'Double quotation marks (")'#=#" Leading Blanks" result5=ABC_123 "123"n "ABC 123"n