如何在DATA步骤中的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;
我希望PUT
之后的/
中的换行符缩进。如何插入制表符?
答案 0 :(得分:3)
以下是一些可能的方法:
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"; run;
将日志重定向到外部文件并在您喜欢的文本编辑器中查看它,那么这将按预期工作,但在SAS日志窗口中(在9.1中。 3至少)不支持制表符 - 它们被视为单个不可打印的字符,显示为矩形。