I'm trying to refer to the labels of variables (to include these in graph titles) when looping on a group of variables to generate graphs. I've tried several methods and changed several functions to plot graphs, but none of these would work. I've also read many previous posts regarding this topic, but even direct copy and past of the code referring to the value label wouldn't work.
here's the code that calls variable labels in loops that I got from a previous post:
"`:label variable `var'' sample1"
(https://www.statalist.org/forums/for...iables-in-loop)

and here's the full code that I'm using:

local y "teacher volunteer "
foreach var of local y {
splitvallabels `var'
catplot gender `var', ///
percent(gender) ///
var1opts(label(labsize(small))) ///
var2opts(label(labsize(small)) relabel(`r(relabel)')) ///
ytitle("Percent of Respondents by gender", size(small)) ///
title("`:label variable `var'' sample1" ///
, span size(medium)) ///
blabel(bar, format(%4.1f)) ///
intensity(25) ///
asyvars
}

This works, but the title wouldn't show the variable label as the stata reports "invalid syntax."

here's the graph I got:
Array
all good--except for the variable label part that's supposed to be included in the title.


This is a fairly simple graph that looks at the percentage by gender who agree/disagree to the statement that they've participated in the project because they liked the teacher/the volunteer who organized it. However, the variable labels are more useful in titles than the variable names. I want this in a loop because I actually have more than two variables to loop (about 20 in total).

Can somebody help me to figure out how I can correctly refer to the variable labels in the loop? Thanks!