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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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