A macro variable created with PROC SQL from a numeric variable or function contains leading blanks:
proc sql;
select count(*) into :howmany from SASHELP.CLASS;
quit;
%put |&howmany|;
| 19|
An easy way to get rid of the leading blanks is as follows:
proc sql;
select count(*) into :howmany separated by ' ' from SASHELP.CLASS;
quit;
%put |&howmany|;
|19|
Posted with thanks to Robert Allison: Since the original post, the TRIMMED option has been added to the INTO clause in PROC SQL to strip blanks:
proc sql;
select count(*) into :howmany trimmed from SASHELP.CLASS;
quit;
%put |&howmany|;
|19|
See the documentation for the INTO clause here.
Thanks to Mike Zdeb for sharing this tip on sasCommunity.org.