Sas 如何在数据步骤中的PUT语句中放置制表符?

Sas 如何在数据步骤中的PUT语句中放置制表符?,sas,datastep,Sas,Datastep,如何在数据步骤中的PUT语句中放置制表符 我正在使用SAS输出处理日志: if first.ref then PUT 'PROCESSING: ' ref ; if InceptionDate > LossDate then do; if first.ref then PUT 'WARNING: ' ref ' inception date prior to the loss date!' / ref= / InceptionD

如何在数据步骤中的PUT语句中放置制表符

我正在使用SAS输出处理日志:

if first.ref then
    PUT 'PROCESSING: ' ref ;

if InceptionDate > LossDate then 
    do; 
        if first.ref then
            PUT 'WARNING: ' ref ' inception date prior to the loss date!' / ref= / InceptionDate= / LossDate=; 
            ... do some stuff...
    end;

我希望
中的换行符在
/
之后缩进。如何插入制表符?

以下是几种可能的方法:

data _null_;
    ref = 001;
    inceptiondate = '01jan1960'd;
    lossdate = '01jun1960'd;
    format inceptiondate lossdate yymmdd10.;

    /*Without indent*/
  PUT 'WARNING: ' ref ' inception date prior to the loss date!' / ref= / InceptionDate= / LossDate=;

    /*Move the pointer to the right by 1 before printing*/
  PUT 'WARNING: ' ref ' inception date prior to the loss date!' /  +1 ref= / +1 InceptionDate= / +1 LossDate=;

    /*Move the pointer to column 2 before printing*/
  PUT 'WARNING: ' ref ' inception date prior to the loss date!' /  @2 ref= / @2 InceptionDate= / @2 LossDate=;


    /*# of spaces seems to depend on where you put the tab characters in the line containing the put statement*/
  PUT 'WARNING: ' ref ' inception date prior to the loss date!' / ' ' ref= / '  ' InceptionDate= / '    ' LossDate=;

    /*Works in external text editor but not in the SAS log window*/
  PUT 'WARNING: ' ref ' inception date prior to the loss date!' / '09'x ref= / '09'x InceptionDate= / '09'x LossDate=;

run;
注释

我不知道如何让这个网站正确显示制表符-第三种方法是编写代码,其中包含单引号中的制表符。如果按照上面显示的方式复制并粘贴代码,则会得到空格。在SAS中,制表符在代码运行之前转换为空格,因此您在日志中的缩进量取决于制表符在代码中的位置,并且日志中包含空格而不是制表符


如果使用'09'x方法,如果您通过
proc printto log=“c:\temp\my.log”将日志重定向到外部文件,则此方法将正常工作;运行并在您喜爱的文本编辑器中查看,但SAS日志窗口(至少在9.1.3中)不支持制表符-它们被视为单个不可打印字符,显示为矩形。

@2将指针移动到行中的第二个字符位置+1从当前位置移动1个字符。如果您确实需要制表符,我喜欢
'09x'
方法。如果您只想缩进,我喜欢
@
选项。
'09'x
解决方案正在SAS中对我的日志工作。例如,我分配了一个宏变量
%LET tab='09'x
,然后在
PUT
语句中使用
选项卡。
。@joe SAS 9.2或更高版本是否在日志窗口中正确显示文字选项卡?