%macro insertv(str,val,i); %*--macro utility module. During macro processing edits macro variable specified by str parm by inserting the value of parm &val starting at location i. If 3nd parm (i) has a value of -1 then macro will append val to the end of str. To preserve leading or trailing blanks in val you need to enclose it using the %str function. For example: str = names and value of &names is "joe john" i = 5 val = %str(mary ): The macro changes the value of &str to joe mary john . Coded by J. Blodgett, oseda, 3-2002. Modified 4/02 to reverse the 2nd and 3rd parms for consistency with usage in geocorr pgm. --*; %*--- i=-1 is signal to append val---; %if &i=-1 %then %let i=%eval(%length(&&&str)+1); %if &i=1 %then %let &str=&val.&&&str; %else %if &i=%eval(%length(&&&str)+1) %then %let &str=&&&str.&val; %else %if &i=0 or &i gt %length(&&&str) %then %put ***Invalid parms passed to insertv macro*** %str( ) str= &str i= &i val= &val; %else %let &str= %substr(&&&str,1,%eval(&i-1))&val.%substr(&&&str,&i); %mend insertv;