First as was mentioned by @ballardw embedded macro definitions are not needed and almost always counter productive. The macro definitions would appear as:
%MACRO NAMEP(prefix,maxnum);
%DO i=1 %to &maxnum;
&prefix&i
%END;
%MEND NAMEP;
%MACRO a(XVAR1=, CCENT=, GCENT=);
%local xvar1n;
....
The better news is that you don't need the %NAMEP macro anyway. Let's look at your other code a bit. This portion counts the number of words in &XVAR1.
%let NXVAR1 = 1;
%do %while(%length(%scan(&XVAR1,&NXVAR1)));
%let NXVAR1 = %EVAL(&NXVAR1 + 1);
%end;
%Let NXVAR1 = %eval(&NXVAR1 -1);
This is simplified with the COUNTW function.
%let NXVAR1 = %sysfunc(countw( &XVAR1));
The call to the %NAMEP is causing an error (unitialized variable because &X1 is not defined). Since you already have a loop. the definition of &XVAR1N can be moved insite the loop.
%else %do;
%Let X1&N1 = &a;
%end;
%let XVAR1n = &xvar1n &&x1&n1;
%end;
%end;
%else %do;
%Let XVAR1n = ;
%end;
%put &XVAR1n;
%mend a;
Notice that &XVAR1N is initialized as a local macro variable just below the macro statement. Other cleanup in the macro is possible, but this should get you started.
... View more