You're always using "Base SAS" no matter how you execute the code.
If this is a macro variable created in a autoexec then there might be a difference between a SAS DI session (like SAS EG created by the Object Spawner) and a PC SAS session - and you might not have fully access to this macro var from within the session (as soon as you batch the job you will have full access).
I can be wrong here but I think that strings assigned to macro vars are always stripped of leading and trailing blanks.
What could be is that you're string is quoted - and an %unquote() could solve the problem.
Have a look at the following example:
%let TESTVAR1= xxx y ;
%put TESTVAR1 unquoted: Length is: %length(&TESTVAR1), Value is: &TESTVAR1;
%let TESTVAR2=%quote( xxx y );
%put TESTVAR2 quoted: Length is: %length(&TESTVAR2), Value is: &TESTVAR2;
%let TESTVAR3=%quote( xxx y );
%put TESTVAR3 quoted/trim: Length is: %length(&TESTVAR3), Value is: &TESTVAR3;
%let TESTVAR4=%quote( xxx y );
%put TESTVAR4 quoted/unquoted: Length is: %length(&TESTVAR4), Value is: &TESTVAR4;