[SAS]方便查询Tips

1-PROC SQL过程步对变量重命名后,可以再次保存该变量一次,宏重命名,写“*”时注意。

e.g.

 

data test; a = "test"; run;

proc sql; select a as b, a from test; run;

2-数值变量字符格式转数值格式,注意下列情况。

data test;
test = "8";
format test test2 test3 8.1;
test1 = input(test, best.); /* 建议*/
test2 = input(test, 8.1); /* 易错*/
test3 = input(test, 8.);
test4 = test2;
run;

/* e.g. 2 error*/

DATA TEST;
TEST = INPUT("8", 8.1); 
RUN;

3-多出导出结果到同一个EXCEL

法1:proc export

法2:ods tagsets.excelxp,例子

法3:ods excel,例子

 4-ods excel提高

官方说明文档例子

5-proc import 导入excel时,导入后变量的长度根据前N行记录判断得到,当记录数较多时,需要设置Options里对N扩大搜索,避免截断。

e.g.

1234567

1234567

...

1234567

...

A123456

...

结果A123456可能导入进来是A12345

 

6-没有报error和warning但无结果导出的例子

SAS EG环境下,

log里提示“

The quoted string currently being processed has become
        more than 262 characters long. You may have unbalanced quotation marks.

原因是使用了* xxx; 格式注释(也称为Asterisk style comments)。

更为/* xxx */注释(也称为 PL/1 style comment),解决。

reference: 1) SAS 官网;

2)SAS 论坛;

posted on 2018-03-12 19:18  ightar  阅读(367)  评论(0编辑  收藏  举报

导航