BookmarkSubscribeRSS Feed
🔒 This topic is locked. We are no longer accepting replies to this topic. Need further help? Please sign in and ask a new question.
SAS_Tipster
Moderator

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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Visit a random SAS tip This SAS Tips board is not open for replies or comments, but we welcome your feedback and questions. Have a question or comment about this tip? Start a new topic in one of our discussion boards, and reference this tip topic.
Discussion stats
  • 0 replies
  • 2438 views
  • 0 likes
  • 1 in conversation