%macro concat( /* Used to concatenate an arg list of up to 20 entries (positional parms). The args can be any expressions, preferably character type, such as a character string within quotes, a single variable name, an expression such as a put function invocation. etc. The single named parm, linkout, controls whether or not the macro generates a "link output;" statement, preceded by a semilcolon to complete the generated concatenated expression. If linkout=0 is specified then no end semicolon and no link output stmt are generated. Sample uses: 1. output_line=%concat("The value of variable A is",a," and the value of B is ",b,".",linkout=0); which results in the value: The value of variable A isaaa and the value of B isbbb. being assigned to output_line. Note that all the character variables are trimmed so you lose trailing blanks. Here "aaa" and "bbb" are assumed to be the values of the character variable a and b, respectively. 2. length l $255; l=%concat('state=',state,' sumlev=',sumlev,' ',geocode,' and the total pop is ', put(totpop,comma9.), '***'); return; output: file '\summary.txt'; put l; Here we show how the program that invokes concat should have an output routine that can be linked to. Typically you use concat to build an outline line and then send the value of the line variable to the output file using the output routine. A sample output line produced by this code looks like this: state=20 sumlev=050 20001 and the total pop is 14,385*** Notice that the 5th argument here, ' ', results in a blank being inserted into the output string. This is because the trim function does not create null strings - trim of a blank is still a blank. */ a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,linkout=1); %if %superq(a1)=%str() %then %do; %put ****Invalid arg list passed to cat macro****; %goto endmac; %end; %local i arg; %let i=1; %let arg=&&&a&i; %do %while(%superq(arg) ne %str()); %if &i ne 1 %then %str( || ); %str( trim(&arg)) %let i=%eval(&i+1); %let arg=&&&a&i; %end; %if &linkout %then %do; ; link output; %end; %endmac: %mend concat;