在SAS中,在数据步骤之外,用空白替换宏变量中的字符的最佳方法是什么?
这似乎TRANSLATE
是一个很好的功能.但是,使用%SYSFUNC
此功能时,参数不会被引号括起来.你怎么指出一个空白应该用作替代?
%str()(在parens之间有空格)可用于指示此参数的空白.也要小心TRANSLATE ...第二个参数是替换字符...但是在TRANWRD中它是相反的.
%macro test ;
%let original= translate_this_var ;
%let replaceWithThis= %str( ) ;
%let findThis= _ ;
%let translated= %sysfunc(translate(&original, &replaceWithThis, &findThis)) ;
%put Original: &original ***** TRANSLATEd: &translated ;
%mend ;
%test;
%macro test2 ;
%let original= translate_this_var ;
%let replaceWithThis= %str( ) ;
%let findThis= _ ;
%let tranwrded= %sysfunc(tranwrd(&original, &findThis, &replaceWithThis)) ;
%put Original: &original ***** TRANWRDed: &tranwrded ;
%mend ;
%test2
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1906 次 |
最近记录: |