BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
larkjr18
Fluorite | Level 6

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?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16
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.

could you please try this.

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

View solution in original post

3 REPLIES 3
Jagadishkatam
Amethyst | Level 16
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.

could you please try this.

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
larkjr18
Fluorite | Level 6

Perfect thank you.

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

Jagadishkatam
Amethyst | Level 16
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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 8493 views
  • 4 likes
  • 2 in conversation