Again I'm doing this from memory. Control variables can be used in all these places.
I tend to use the ASK command to present a menu and set the dates. A single selection from ASK can set many variables.
Then I have a shell proc with command like
set period Jan - &myvar
calc var2 = average(var1) for &myvar
in some cases this proc can be run as it stands. In other cases the control var won't resolve. In this case I then have a command that does something like
copy pro myshellproc myexecuteproc resolve
compile myexecuteproc
exe myexecueproc
You'll need to play with the technique but once you understand it you can do all sorts of magic.