Simple answer: don't. If any other coder has to maintain such code, you're dead. Even if you emigrated to another continent. They'll track you down just to make an example of you.
Just to show you what kind of abomination results out of such mindless abuse of the macro preprocessor, here's the solution:
%let I=1; %let zone_1=SOUTH; %let SOUTH_STATE_1=DL; %let third_part=_state_1; %put &&&&&&zone_&i.&&third_part.;
33 %put &&&&&&zone_&i.&&third_part.; DL
Note that I had to make up another macro variable to satisfy the necessary levels of indirection.
How to do without third_part
But you can try to do it in a data step (which I recommend for complicated string operations anyway):
%let I=1; %let zone_1=SOUTH; %let SOUTH_STATE_1=DL; data _null_; name1 = resolve('&' !! resolve('&zone_' !! "&i") !! '_state_1'); call symputx('result',name1); run; %put &result;
37 %put &result; DL
I would agree that this level of complexity probably needs to be fixed earlier in the process.
Try doing it piece by piece to see how to get there. For example you could start with just getting the value of macro variable I resolved.
776 %PUT ZONE_&I._STATE_&I.; ZONE_1_STATE_1
Now you want to have the ZONE_1 part resolved. So add a double &&. Make sure to add another period so it doesn't try to resolve ZONE_1_STATE_1 instead.
777 %PUT &&ZONE_&I.._STATE_&I.; SOUTH_STATE_1
So now you have the name of the macro variable you want to resolve. So again you need to add &&, but since you already are using that trick once to get ZONE_1 to resolve you need to double each of the new &'s.
778 %PUT &&&&&&ZONE_&I.._STATE_&I.; DL
But it is probably easier to just build up the name into a new macro variable and then use triple & to show the value of variable whose name is in a variable.
So make ZONE_1
Then get the value of ZONE_1.
Then tack on STATE_1.
Now use the value of MVAR as the NAME of the macro variable you want to display.
785 %put &=mvar; MVAR=SOUTH_state_1 786 %put &&&mvar; DL
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.