It seems SAS Macro adds a space when there is a line break as follows:
%let Sentence=The line break in this sentence
will leave a space.;
%put &Sentence;
SAS prints the following output:
1 %let Sentence=The line break in this sentence 2 will leave a space.; 3 4 %put &Sentence; The line break in this sentence will leave a space.
Is there any way to avoid this spacing and let SAS print The line break in this sentencewill leave a space.
instead? This is not a SAS example, but like %
in LaTeX as follows:
\documentclass{article} \begin{document} The line break in this sentence will leave a space. However, the line break in this sentence% won't leave a space. \end{document}
Thanks for your help!
If you want to make a long macro variable but keep the source lines short here are a couple of ways.
Macro code only: Use multiple %LET statements.
%let Sentence=The line break in this sentence;
%let Sentence=&sentence.will NOT leave a space before will.;
SAS code: Use multiple string literals and CALL SYMPUTX()
data _null_;
call symputx('Sentence'
,'The line break in this sentence'
||'will NOT leave a space before will.'
);
run;;
Note: if you need the macro variable to contain leading and/or trailing spaces you can use the ANCIENT CALL SYMPUT() instead.
If you want to make a long macro variable but keep the source lines short here are a couple of ways.
Macro code only: Use multiple %LET statements.
%let Sentence=The line break in this sentence;
%let Sentence=&sentence.will NOT leave a space before will.;
SAS code: Use multiple string literals and CALL SYMPUTX()
data _null_;
call symputx('Sentence'
,'The line break in this sentence'
||'will NOT leave a space before will.'
);
run;;
Note: if you need the macro variable to contain leading and/or trailing spaces you can use the ANCIENT CALL SYMPUT() instead.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.