SAS check field by field

2019-08-20 03: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条回答
男人必须洒脱
2楼-- · 2019-08-20 03:53
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.

查看更多
登录 后发表回答