I don't know enough about Proc IML to tell if it allows you to replace a source table.
You've nicely commented your code and it doesn't say anywhere "write" or "update" - which is what's missing.
Here a link how such a write could look like:
And here docu sample code how to update data:
I don't have a matrix to test this on, but I think this ought to work
where = loc(m=-99 or m=99); m[where]=.;
No loops needed (in general, you don't want to use loops in IML anyway, you want to use matrix commands; the only time you would use loops is if you are developing some sort of iterative algorithm)
If you receive values that you know are going to be set to missing, such as with an indicator code like this, you might consider reading the data into missing to begin with.
proc format library=work; invalue myvalues '99', '-99' = . ; run; /* reading raw data*/ data example; input v1 :myvalues. ; datalines; 1 2 9 99 -99 -45 45 ;
Another option would be use an assignment of special missing in the format like .Z (replace the . in the invalue with .Z )that would allow you to tell the difference between missing because no value was read or the missing set due to this rule. The value is still missing for purposes of calculations but can be printed or examined.
Why not post it at IML forum ? since it is IML question ? @Rick_SAS is there.
data example; input v1 ; v2=v1; datalines; 1 2 9 99 -99 -45 45 ; proc iml; use example; read all var _all_ into x[c=vname]; close; x[loc(x=99 | x=-99)]=.; create want from x[c=vname]; append from x; close; quit;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.