sas - 如何在 SAS 中编写 ods 乳胶模板
问题描述
基于此文档:
https://support.sas.com/resources/papers/proceedings14/2033-2014.pdf
我创建了附加的结果并使用附加的代码,
但我想生成我自己的模板来创建输出(具有多行和部分网格的表):
有谁知道如何实现这一目标?或者是学习编写 ods 模板中使用的语言的好来源。非常感谢!
ods path(prepend) work.templat(update);
proc template;
define tagset Tagsets.event1;
define event colspec_entry;
put just "|" /if ^cmp( just, "d");
put "r|" /if cmp( just, "d");
end;
define event table;
start:
put NL;
put NL;
put "\begin{longtable}";
finish:
put "\hline \end{longtable}" NL;
put NL;
end;
define event stacked_cell;
start:
put NL;
put "\begin{tabular}";
trigger alignment;
finish:
put "\end{tabular}" NL;
end;
define event colspecs;
start:
put "{";
finish:
put "}\hline" NL;
end;
define event colspec_entry;
put just /if ^cmp( just, "d");
put "r" /if cmp( just, "d");
end;
define event row;
finish:
put "\\" NL;
end;
define event header;
start:
trigger data;
finish:
trigger data;
end;
define event data;
start:
put VALUE /if cmp( $sascaption, "true");
break /if cmp( $sascaption, "true");
put %nrstr(" & ") /if ^cmp( COLSTART, "1");
put " ";
unset $colspan;
set $colspan colspan;
do /if exists( $colspan) | exists ( $cell_align );
put "\multicolumn{";
put colspan /if $colspan;
put "1" /if ^$colspan;
put "}{";
put "|" /if ^$instacked;
put just;
put "|" /if ^$instacked;
put "}{";
done;
put tranwrd(VALUE,"-","$-$") /if contains( HTMLCLASS, "data");
put VALUE /if ^contains( HTMLCLASS, "data");
finish:
break /if cmp( $sascaption, "true");
put "}" /if exists( $colspan) | exists ( $cell_align );
end;
define event rowspanfillsep;
put %nrstr(" & ");
end;
define event rowspancolspanfill;
put " ~";
end;
define event image;
put "\includegraphics{";
put BASENAME /if ^exists( NOBASE);
put URL;
put "}" NL;
end;
parent = tagsets.latex;
end;
run;
data t;
length v1 $20;
input v1 $ v2;
datalines;
f=ma 21
sqrt(abd) 22
;
run;
ods tagsets.simplelatex file="/scratch/columbia/zz89/t1.tex";
proc print data=t;
run;
ods tagsets.simplelatex close;
ods tagsets.event1 file="/scratch/columbia/zz89/t2.tex";
proc print data=t;
run;
ods tagsets.event1 close;
data re1;
infile "/scratch/columbia/zz89/t1.tex" pad missover;
file "/scratch/columbia/zz89/t1_out.tex";
length c1 $200;
input c1 $ 1-200;
p1=index(c1,'sqrt');
if p1>0 then do;
c2=substr(c1,(p1+5));
p2=index(c2,')');
c3=substr(c1,1,(p1-1))||'$\sqrt{'||scan(c2,1,')') ||'}$'||substr(c2,(p2+1));
put c3;
end;
else put c1;
run;
解决方案
推荐阅读
- arrays - 正确语法以将超链接从数组添加到 Excel 工作表
- twitter-bootstrap - 如何使用 Vuejs 和 twitter 引导程序创建模态对话框
- sql-server - SQL Server - 从旧数据库转换短日期
- python - Tensorboard 未显示 GPU 设备
- c++ - Qt:我如何堆叠小部件以在它们之间进行转换,通过淡入和淡出?
- apache-flink - Flink TaskManager 超时?
- scala - Scala如何根据大小使用不同的Class来实现Map和Set的性能提升?
- linux - 在安全启动的情况下执行 rdmsr / wrmsr?
- scala - 更新 ScalikeJDBC 中的返回查询
- mysql - 如何重命名在mysql中用作外键的字段?