SAS check field by field

白昼怎懂夜的黑 提交于 2019-12-11 14:05:18

问题


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;

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!

Best regards


回答1:


length flag $10.;
if whichn(0, of L_contract -- l_customer_retail) then flag='Not Ok';
else flag='Ok';

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.

Edit: change single dash to two dashes.



来源:https://stackoverflow.com/questions/52954188/sas-check-field-by-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!