SAS Programmers:
I have a SAS data set with multiple variables. I want to replace one outlier's measured and derived values in the data set with missing values. This can be done using multiple logical if-then statements, but is there a more concise way of doing this, i.e. a single statement indicating the range or span of variables to replace with missing values? For example the following observation in the data set:
Obs_Num Trt1 Trt2 Tr3 Block Var1..................V20
Here, I want to replace Var5.....Var10 with missing values while retaining everything else.
Any suggestions?
Thanks!
Something like this in your data step ought to work:
call missing(of var5-var10);
Something like this in your data step ought to work:
call missing(of var5-var10);
Thanks for the speedy reply. However I believe the call missing routine as written is global. What I need is something like this:
For a single outlier. As you can see, SAS doesn't like this.
Thanks!
You have made a syntax error. SAS would like it if you used this code:
if obs='268' then call missing (of par--sqrtpar);
In the future, please do not paste code or SAS log as pictures, paste the actual SASLOG text into the {i} window.
Thanks, that worked. Sorry for posting the image.
@Kip1 wrote:
Thanks, that worked. Sorry for posting the image.
The reason we request code or log entries to be pasted as text is because depending on what is requested we either have or make dummy data to test your code against. If we have to type lines of code that is less likely to happen and possibly result in no answers.
Also for code suggestions it may be much easier to copy and paste your code, edit it and then paste back here with highlights to clarify a point.
Your code was relatively short but we have had programs running way longer than that.
Got it. Thanks.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.