SAS逐字段检查 [英] SAS check field by field
问题描述
我尝试建立一点检查过程。一个 proc sql
生成了一个行表(和13个字段),下一步,我需要检查表中的选定字段是否具有 value<>。 0
。
在示例代码为拥有
的当前(未完成)代码下面:
I try build little check process. One proc sql
generated one row table (and 13 fields) and next step I need check that chosen field in the table has value <> 0
.
Below my current (not completed) code with example table "have"
:
data Have;
input REFERENCE_DATE
L_CONTRACT
L_CONTRACT_ACTIVITY
L_LFC
L_CONTRACT_CO_CUSTOMER
L_CONTRACT_OBJECT
L_CUSTOMER
L_CUSTOMER_RETAIL
L_DPD
L_GL_ACCOUNT
L_GL_AMOUNT
L_EXTRA_COST
L_PRODUCT;
datalines;
450 1 9 8 6 0 4 3 0 0 0 0 0
;
Data work.Collect_data2;
set work.have;
ARRAY tab(13) _temporary_ (0,0,0,0,0,0,0,0,0,0,0,0,0) ;
ARRAY tab_check(*) L_CONTRACT-L_CUSTOMER_RETAIL;
input id L_CONTRACT-L_CUSTOMER_RETAIL;
do j= 2 to 7;
end;
run;
自L_CONTRACT到L_CUSTOMER_RETAIL(字段2至7)以来,我需要逐字段检查。
如果此段中的任何字段的值都为0-我需要返回信息,表明某些操作不正确。
感谢您的帮助!
I need to check field by field since L_CONTRACT to L_CUSTOMER_RETAIL (field 2 to 7). If anyfield from this pieces has value = 0 - I need return info that something is not ok. Thanks for help!
最诚挚的问候
推荐答案
length flag $10.;
if whichn(0, of L_contract -- l_customer_retail) then flag='Not Ok';
else flag='Ok';
您可以使用 WHICHN()
函数测试一系列变量中的任何值是否为0。不需要数组声明。我对为什么您有 INPUT
语句以及 SET
语句但没有 INFILE
或 CARDS。这对我来说没有意义。
You can use the WHICHN()
function to test if any value is 0 in a series of variables. No array declarations needed. I'm confused as to why you have an INPUT
statement along with a SET
statement but no INFILE
or 'CARDS` though. That doesn't make sense to me.
编辑:将单个破折号更改为两个破折号。
change single dash to two dashes.
这篇关于SAS逐字段检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!