## How to replace values of set of variables

Solved
Occasional Contributor
Posts: 14

# How to replace values of set of variables

[ Edited ]

Hi guys,

Can someone help me to change the dataset according to the following?

Thank you.

Khalid

Accepted Solutions
Solution
‎04-11-2017 12:31 PM
PROC Star
Posts: 8,150

## Re: How to replace values of set of variables

Nothing wrong with grouping them together. e.g.:

```data want;
set have;
if v1=v2=v3=8 then call missing(of v1-v3);
run;
```

Art, CEO, AnalystFinder.com

All Replies
Super User
Posts: 23,343

## Re: How to replace values of set of variables

Whats the rule? All 8s or all the same value? What if you have two the same value and one is missing.

You can use MIN/MAX logic - if the min=max then the values are the same and you can use CALL MISSING to set variables to missing.

Useful functions:

N - returns number of non missing

NMISS - returns the number of missing

MIN - returns minimum value

MAX - returns max value

CALL MISSING() - sets variables designated to as missing - doesn't matter if they're character or numeric.

PS. Post data not in images but at least as text, ideally as a data step. We can't write code based on an image so that would mean typing out your dataset.

PROC Star
Posts: 8,150

## Re: How to replace values of set of variables

or just use something like:

```data want;
set have;
array vars(*) v1-v3;
if v1=v2=v3 then call missing(of vars(*));
run;
```

Art, CEO, AnalystFinder.com

Occasional Contributor
Posts: 14

## Re: How to replace values of set of variables

I want 'if v1=v2=v3=8 THEN 'v1=v2=v3=missing'.
Occasional Contributor
Posts: 14

## Re: How to replace values of set of variables

Thank you for your comments. I want to consider 8s as missing when they are in all variables. For example, if v1=v2=v3=8, then

v1=v2=v3=missing. @Reeza

Super User
Posts: 23,343

## Re: How to replace values of set of variables

If v1=8 and v2=8 and v3 =8 then call missing(v1, v2, v3);

Solution
‎04-11-2017 12:31 PM
PROC Star
Posts: 8,150

## Re: How to replace values of set of variables

Nothing wrong with grouping them together. e.g.:

```data want;
set have;
if v1=v2=v3=8 then call missing(of v1-v3);
run;
```

Art, CEO, AnalystFinder.com

Occasional Contributor
Posts: 14

## Re: How to replace values of set of variables

Awesome! Thank you @art297
☑ This topic is solved.