Rick:

My students struggle with scope in SAS/IML, so this article will be useful to them. However your final (global) example has a typo in that your F3 function defines M
y=3*x
but your output and diagram depict the multiplier of x to be 2.