【发布时间】:2018-09-14 11:46:33
【问题描述】:
我正在寻找一个程序来清理我拥有的一些混乱数据,我希望为我正在从事的项目的资产和负债方面这样做。
我的问题是有一种方法可以使用 do 循环来使用清理数据首先清理资产然后清理负债。像这样:
%do %I = Asset %to Liability;
%assetorliability= I ;
proc sort data = &assetorliability;
by price;
run;
data want&assetorliability;
set &assetorliability;
if _N_ < 50000;
run;
实际的脚本很长,所以单个宏可能不是理想的解决方案,但这个循环会很棒。
TIA。
编辑:程序包含一些宏,收到的错误如下:
%let list =Asset Liability;
%do i=1 %to %sysfunc(countw(&list,%str( )));
%let next=%scan(&list,&i,%str( ));
%Balance;
%end;
在宏中,数据步骤以平衡和列表命名,以允许每个场景。错误是:
13221 %let list =Asset Liability;
13222 %do i=1 %to %sysfunc(countw(&list,%str( )));
ERROR: The %DO statement is not valid in open code.
13223
13224 %let next=%scan(&list,&i,%str( ));
WARNING: Apparent symbolic reference I not resolved.
WARNING: Apparent symbolic reference I not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric
operand is required. The condition was: &i
ERROR: Argument 2 to macro function %SCAN is not a number.
ERROR: The %END statement is not valid in open code.
【问题讨论】:
-
如果你想使用
%do(或%if)那么你需要把它包装成一个宏。
标签: macros sas do-loops sas-studio