Solved
Contributor
Posts: 25

# arrays to change values to missing

array change (6) gpa, sat, satm, satv, act, toefl;
do i = 1 TO 6;
if change(i) = 0 then change(i) = 'missing';
end;
run;

want to make this array change each 0 value to missing but it isnt working...

any suggestions?

Accepted Solutions
Solution
‎03-27-2017 09:53 PM
Posts: 1,147

## Re: arrays to change values to missing

You are trying to update the numeric variables values to character value 'missing'. Hence it is not working i guess. Please try to create new character variables corresponding to the numeric variables and in them you could populate the missing value if the corresponding numeric values is zero in those variables.

array change(6) gpa sat satm satv act toefl;
array changec(6)\$10 gpac satc satmc satvc actc toeflc;
do i = 1 TO 6;
if change(i) = 0 then changec(i) = 'missing';
else changec(i) = put(change(i),best.);
end;
run;
Thanks,
Jag

All Replies
Solution
‎03-27-2017 09:53 PM
Posts: 1,147

## Re: arrays to change values to missing

You are trying to update the numeric variables values to character value 'missing'. Hence it is not working i guess. Please try to create new character variables corresponding to the numeric variables and in them you could populate the missing value if the corresponding numeric values is zero in those variables.

array change(6) gpa sat satm satv act toefl;
array changec(6)\$10 gpac satc satmc satvc actc toeflc;
do i = 1 TO 6;
if change(i) = 0 then changec(i) = 'missing';
else changec(i) = put(change(i),best.);
end;
run;
Thanks,
Jag
Contributor
Posts: 25

## Re: arrays to change values to missing

Perfect thank you.

If I wanted to keep it a numeric value could I use my old code and just use (missing) or something?

Posts: 1,147

## Re: arrays to change values to missing

Yes, if you want to make the zero to missing (.) then yes you could use your old code. But i think in the array you cannot separate the variables by comma as they will be considered as values , just separate the variables in array by space.

array change(6) gpa sat satm satv act toefl;
do i = 1 TO 6;
if change(i) = 0 then change(i) =.;
end;
Thanks,
Jag
☑ This topic is solved.