SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

A basic question of array statement

Reply
Frequent Contributor
Posts: 75

A basic question of array statement

I have several variables, let's say V1 to V3, each of them containing values of 1 or 0.

How to write a statement for an array of these variables, so that a new variable (e.g., V4) will receive value of 1 if any among V1-V3 is 1; and 0 otherwise (i.e., all among V1-V3 are 0s)?

Trusted Advisor
Posts: 1,228

Re: A basic question of array statement

Posted in reply to NonSleeper

data want;

set have;

if sum(of v1-v3)>0 then v4=1;

else v4=0;

run;

Super User
Posts: 11,343

Re: A basic question of array statement

Posted in reply to NonSleeper

v4= max(of v1-v3);

would also work.

What would you want if all of v1 - v3 are missing though?

Ask a Question
Discussion stats
  • 2 replies
  • 272 views
  • 0 likes
  • 3 in conversation