Sas 如何使用CATX函数连接空间?

Sas 如何使用CATX函数连接空间?,sas,sas-macro,Sas,Sas Macro,我需要形成一行连接数字和字符串,但用空格分隔 我试了5种方法,但都没有达到预期的效果 %LET lim1 = 113; %LET lim2 = 166; 测试1: %LET linha = %SYSFUNC(CATS(De,&lim1,a,&lim2,clientes)); %PUT &linha; De113a166clientes %LET linha = %SYSFUNC(CATS('De ',&lim1,' a ',&lim2,' clien

我需要形成一行连接数字和字符串,但用空格分隔

我试了5种方法,但都没有达到预期的效果

%LET lim1 = 113;
%LET lim2 = 166;
测试1:

%LET linha = %SYSFUNC(CATS(De,&lim1,a,&lim2,clientes));
%PUT &linha;
De113a166clientes
%LET linha = %SYSFUNC(CATS('De ',&lim1,' a ',&lim2,' clientes'));
%PUT &linha;
30         %LET linha = %SYSFUNC(CATS('De ',&lim1,' a ',&lim2,' clientes'));
NOTE: Line generated by the macro function "SYSFUNC".
30          'De '113' a '166' clientes'
            _____   _____
            49      49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
             
%LET linha = %SYSFUNC(CATX(' ','De ',&lim1,' a ',&lim2,' clientes'));
%PUT &linha;
29         %LET linha = %SYSFUNC(CATX(' ','De ',&lim1,' a ',&lim2,' clientes'));
NOTE: Line generated by the macro function "SYSFUNC".
29          'De '' '113' '' a '' '166' '' clientes'
            ________   ___________
            49         49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
%LET linha = %SYSFUNC(CATX(' ',De,&lim1,a,&lim2,clientes));
%PUT &linha;
NOTE: Line generated by the macro function "SYSFUNC".
29          De' '113' 'a' '166' 'clientes
              ___   ___ ___   ___
              49    49  49    49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
%LET linha = %SYSFUNC(CATX(*,De,&lim1,a,&lim2,clientes));
%PUT &linha;
De*113*a*166*clientes
输出1:

%LET linha = %SYSFUNC(CATS(De,&lim1,a,&lim2,clientes));
%PUT &linha;
De113a166clientes
%LET linha = %SYSFUNC(CATS('De ',&lim1,' a ',&lim2,' clientes'));
%PUT &linha;
30         %LET linha = %SYSFUNC(CATS('De ',&lim1,' a ',&lim2,' clientes'));
NOTE: Line generated by the macro function "SYSFUNC".
30          'De '113' a '166' clientes'
            _____   _____
            49      49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
             
%LET linha = %SYSFUNC(CATX(' ','De ',&lim1,' a ',&lim2,' clientes'));
%PUT &linha;
29         %LET linha = %SYSFUNC(CATX(' ','De ',&lim1,' a ',&lim2,' clientes'));
NOTE: Line generated by the macro function "SYSFUNC".
29          'De '' '113' '' a '' '166' '' clientes'
            ________   ___________
            49         49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
%LET linha = %SYSFUNC(CATX(' ',De,&lim1,a,&lim2,clientes));
%PUT &linha;
NOTE: Line generated by the macro function "SYSFUNC".
29          De' '113' 'a' '166' 'clientes
              ___   ___ ___   ___
              49    49  49    49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
%LET linha = %SYSFUNC(CATX(*,De,&lim1,a,&lim2,clientes));
%PUT &linha;
De*113*a*166*clientes
测试2:

%LET linha = %SYSFUNC(CATS(De,&lim1,a,&lim2,clientes));
%PUT &linha;
De113a166clientes
%LET linha = %SYSFUNC(CATS('De ',&lim1,' a ',&lim2,' clientes'));
%PUT &linha;
30         %LET linha = %SYSFUNC(CATS('De ',&lim1,' a ',&lim2,' clientes'));
NOTE: Line generated by the macro function "SYSFUNC".
30          'De '113' a '166' clientes'
            _____   _____
            49      49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
             
%LET linha = %SYSFUNC(CATX(' ','De ',&lim1,' a ',&lim2,' clientes'));
%PUT &linha;
29         %LET linha = %SYSFUNC(CATX(' ','De ',&lim1,' a ',&lim2,' clientes'));
NOTE: Line generated by the macro function "SYSFUNC".
29          'De '' '113' '' a '' '166' '' clientes'
            ________   ___________
            49         49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
%LET linha = %SYSFUNC(CATX(' ',De,&lim1,a,&lim2,clientes));
%PUT &linha;
NOTE: Line generated by the macro function "SYSFUNC".
29          De' '113' 'a' '166' 'clientes
              ___   ___ ___   ___
              49    49  49    49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
%LET linha = %SYSFUNC(CATX(*,De,&lim1,a,&lim2,clientes));
%PUT &linha;
De*113*a*166*clientes
输出2(错误):

%LET linha = %SYSFUNC(CATS(De,&lim1,a,&lim2,clientes));
%PUT &linha;
De113a166clientes
%LET linha = %SYSFUNC(CATS('De ',&lim1,' a ',&lim2,' clientes'));
%PUT &linha;
30         %LET linha = %SYSFUNC(CATS('De ',&lim1,' a ',&lim2,' clientes'));
NOTE: Line generated by the macro function "SYSFUNC".
30          'De '113' a '166' clientes'
            _____   _____
            49      49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
             
%LET linha = %SYSFUNC(CATX(' ','De ',&lim1,' a ',&lim2,' clientes'));
%PUT &linha;
29         %LET linha = %SYSFUNC(CATX(' ','De ',&lim1,' a ',&lim2,' clientes'));
NOTE: Line generated by the macro function "SYSFUNC".
29          'De '' '113' '' a '' '166' '' clientes'
            ________   ___________
            49         49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
%LET linha = %SYSFUNC(CATX(' ',De,&lim1,a,&lim2,clientes));
%PUT &linha;
NOTE: Line generated by the macro function "SYSFUNC".
29          De' '113' 'a' '166' 'clientes
              ___   ___ ___   ___
              49    49  49    49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
%LET linha = %SYSFUNC(CATX(*,De,&lim1,a,&lim2,clientes));
%PUT &linha;
De*113*a*166*clientes
测试3:

%LET linha = %SYSFUNC(CATS(De,&lim1,a,&lim2,clientes));
%PUT &linha;
De113a166clientes
%LET linha = %SYSFUNC(CATS('De ',&lim1,' a ',&lim2,' clientes'));
%PUT &linha;
30         %LET linha = %SYSFUNC(CATS('De ',&lim1,' a ',&lim2,' clientes'));
NOTE: Line generated by the macro function "SYSFUNC".
30          'De '113' a '166' clientes'
            _____   _____
            49      49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
             
%LET linha = %SYSFUNC(CATX(' ','De ',&lim1,' a ',&lim2,' clientes'));
%PUT &linha;
29         %LET linha = %SYSFUNC(CATX(' ','De ',&lim1,' a ',&lim2,' clientes'));
NOTE: Line generated by the macro function "SYSFUNC".
29          'De '' '113' '' a '' '166' '' clientes'
            ________   ___________
            49         49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
%LET linha = %SYSFUNC(CATX(' ',De,&lim1,a,&lim2,clientes));
%PUT &linha;
NOTE: Line generated by the macro function "SYSFUNC".
29          De' '113' 'a' '166' 'clientes
              ___   ___ ___   ___
              49    49  49    49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
%LET linha = %SYSFUNC(CATX(*,De,&lim1,a,&lim2,clientes));
%PUT &linha;
De*113*a*166*clientes
输出3(错误):

%LET linha = %SYSFUNC(CATS(De,&lim1,a,&lim2,clientes));
%PUT &linha;
De113a166clientes
%LET linha = %SYSFUNC(CATS('De ',&lim1,' a ',&lim2,' clientes'));
%PUT &linha;
30         %LET linha = %SYSFUNC(CATS('De ',&lim1,' a ',&lim2,' clientes'));
NOTE: Line generated by the macro function "SYSFUNC".
30          'De '113' a '166' clientes'
            _____   _____
            49      49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
             
%LET linha = %SYSFUNC(CATX(' ','De ',&lim1,' a ',&lim2,' clientes'));
%PUT &linha;
29         %LET linha = %SYSFUNC(CATX(' ','De ',&lim1,' a ',&lim2,' clientes'));
NOTE: Line generated by the macro function "SYSFUNC".
29          'De '' '113' '' a '' '166' '' clientes'
            ________   ___________
            49         49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
%LET linha = %SYSFUNC(CATX(' ',De,&lim1,a,&lim2,clientes));
%PUT &linha;
NOTE: Line generated by the macro function "SYSFUNC".
29          De' '113' 'a' '166' 'clientes
              ___   ___ ___   ___
              49    49  49    49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
%LET linha = %SYSFUNC(CATX(*,De,&lim1,a,&lim2,clientes));
%PUT &linha;
De*113*a*166*clientes
测试4:

%LET linha = %SYSFUNC(CATS(De,&lim1,a,&lim2,clientes));
%PUT &linha;
De113a166clientes
%LET linha = %SYSFUNC(CATS('De ',&lim1,' a ',&lim2,' clientes'));
%PUT &linha;
30         %LET linha = %SYSFUNC(CATS('De ',&lim1,' a ',&lim2,' clientes'));
NOTE: Line generated by the macro function "SYSFUNC".
30          'De '113' a '166' clientes'
            _____   _____
            49      49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
             
%LET linha = %SYSFUNC(CATX(' ','De ',&lim1,' a ',&lim2,' clientes'));
%PUT &linha;
29         %LET linha = %SYSFUNC(CATX(' ','De ',&lim1,' a ',&lim2,' clientes'));
NOTE: Line generated by the macro function "SYSFUNC".
29          'De '' '113' '' a '' '166' '' clientes'
            ________   ___________
            49         49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
%LET linha = %SYSFUNC(CATX(' ',De,&lim1,a,&lim2,clientes));
%PUT &linha;
NOTE: Line generated by the macro function "SYSFUNC".
29          De' '113' 'a' '166' 'clientes
              ___   ___ ___   ___
              49    49  49    49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
%LET linha = %SYSFUNC(CATX(*,De,&lim1,a,&lim2,clientes));
%PUT &linha;
De*113*a*166*clientes
输出4(错误):

%LET linha = %SYSFUNC(CATS(De,&lim1,a,&lim2,clientes));
%PUT &linha;
De113a166clientes
%LET linha = %SYSFUNC(CATS('De ',&lim1,' a ',&lim2,' clientes'));
%PUT &linha;
30         %LET linha = %SYSFUNC(CATS('De ',&lim1,' a ',&lim2,' clientes'));
NOTE: Line generated by the macro function "SYSFUNC".
30          'De '113' a '166' clientes'
            _____   _____
            49      49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
             
%LET linha = %SYSFUNC(CATX(' ','De ',&lim1,' a ',&lim2,' clientes'));
%PUT &linha;
29         %LET linha = %SYSFUNC(CATX(' ','De ',&lim1,' a ',&lim2,' clientes'));
NOTE: Line generated by the macro function "SYSFUNC".
29          'De '' '113' '' a '' '166' '' clientes'
            ________   ___________
            49         49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
%LET linha = %SYSFUNC(CATX(' ',De,&lim1,a,&lim2,clientes));
%PUT &linha;
NOTE: Line generated by the macro function "SYSFUNC".
29          De' '113' 'a' '166' 'clientes
              ___   ___ ___   ___
              49    49  49    49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
%LET linha = %SYSFUNC(CATX(*,De,&lim1,a,&lim2,clientes));
%PUT &linha;
De*113*a*166*clientes
测试5:

%LET linha = %SYSFUNC(CATS(De,&lim1,a,&lim2,clientes));
%PUT &linha;
De113a166clientes
%LET linha = %SYSFUNC(CATS('De ',&lim1,' a ',&lim2,' clientes'));
%PUT &linha;
30         %LET linha = %SYSFUNC(CATS('De ',&lim1,' a ',&lim2,' clientes'));
NOTE: Line generated by the macro function "SYSFUNC".
30          'De '113' a '166' clientes'
            _____   _____
            49      49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
             
%LET linha = %SYSFUNC(CATX(' ','De ',&lim1,' a ',&lim2,' clientes'));
%PUT &linha;
29         %LET linha = %SYSFUNC(CATX(' ','De ',&lim1,' a ',&lim2,' clientes'));
NOTE: Line generated by the macro function "SYSFUNC".
29          'De '' '113' '' a '' '166' '' clientes'
            ________   ___________
            49         49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
%LET linha = %SYSFUNC(CATX(' ',De,&lim1,a,&lim2,clientes));
%PUT &linha;
NOTE: Line generated by the macro function "SYSFUNC".
29          De' '113' 'a' '166' 'clientes
              ___   ___ ___   ___
              49    49  49    49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
%LET linha = %SYSFUNC(CATX(*,De,&lim1,a,&lim2,clientes));
%PUT &linha;
De*113*a*166*clientes
Out 5:

%LET linha = %SYSFUNC(CATS(De,&lim1,a,&lim2,clientes));
%PUT &linha;
De113a166clientes
%LET linha = %SYSFUNC(CATS('De ',&lim1,' a ',&lim2,' clientes'));
%PUT &linha;
30         %LET linha = %SYSFUNC(CATS('De ',&lim1,' a ',&lim2,' clientes'));
NOTE: Line generated by the macro function "SYSFUNC".
30          'De '113' a '166' clientes'
            _____   _____
            49      49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
             
%LET linha = %SYSFUNC(CATX(' ','De ',&lim1,' a ',&lim2,' clientes'));
%PUT &linha;
29         %LET linha = %SYSFUNC(CATX(' ','De ',&lim1,' a ',&lim2,' clientes'));
NOTE: Line generated by the macro function "SYSFUNC".
29          'De '' '113' '' a '' '166' '' clientes'
            ________   ___________
            49         49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
%LET linha = %SYSFUNC(CATX(' ',De,&lim1,a,&lim2,clientes));
%PUT &linha;
NOTE: Line generated by the macro function "SYSFUNC".
29          De' '113' 'a' '166' 'clientes
              ___   ___ ___   ___
              49    49  49    49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
%LET linha = %SYSFUNC(CATX(*,De,&lim1,a,&lim2,clientes));
%PUT &linha;
De*113*a*166*clientes
测试5与我所需要的尽可能接近,但我需要用一个空格替换*

我需要:
De 113 a 166个客户


不幸的是,我没有成功。

在宏中,组装源代码文本不需要使用
CAT

只需在所需的上下文中解析宏变量

%LET lim1 = 113;
%LET lim2 = 166;
%LET linha = De &lim1 a &lim2 clientes;
%PUT &=linha;
----- LOG -----
LINHA=De 113 a 166 clientes
如果在带引号的字符串或字符串值计算的数据步骤上下文中使用宏变量值,则解析应在字符串文字的双引号内(除非宏值已经是双引号文字)


难以置信。