Without SAS, your macros and such, I have no way of testing that. I guess you have defined sampath as a global variable and assigned the value elsewhere?

I guess the "m" in sampath means path for SAS macros. You have some other variables with no apparent values as well. That is why I set Option Explicit as first line of code in a Module and Compile code before a run.