SAS逐个字段检查并在0时放置字段名称 [英] SAS check field by field and put field name when 0

查看:21
本文介绍了SAS逐个字段检查并在0时放置字段名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题与以下主题有关:逐个字段检查SAS.如果字段的值为 0,我正在搜索将(放置)设置为列的字符串/变量名称的方法.有没有优雅的方法?

My question is related with below topic: SAS check field by field. I'm searching method which set (put) to string/variable name of columns if field has value of 0. Is there an elegant method for the?

最好的问候!

推荐答案

VNAME函数会返回一个数组引用对应的变量名.

The VNAME function will return the name of the variable corresponding to an array reference.

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 want;
  length vars_with_zero $1000;
  set have;
  array L L_CONTRACT -- L_CUSTOMER_RETAIL;

  * accumulate the names of the variables that have a zero value;
  do _n_ = 1 to dim(L);
    if L(_n_) = 0 then vars_with_zero = catx(' ', vars_with_zero, vname(L(_n_)));
  end;
run;

这篇关于SAS逐个字段检查并在0时放置字段名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆