Reputation: 87
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?
Best regards!
Upvotes: 0
Views: 52
Reputation: 27508
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;
Upvotes: 1