SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Kip1
Calcite | Level 5

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!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Something like this in your data step ought to work:

 

call missing(of var5-var10);
--
Paige Miller

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

Something like this in your data step ought to work:

 

call missing(of var5-var10);
--
Paige Miller
Kip1
Calcite | Level 5

Thanks for the speedy reply. However I believe the call missing routine as written is global. What I need is something like this:

 

Capture.JPG

For a single outlier. As you can see, SAS doesn't like this.

 

Thanks! 

 

 

PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
Kip1
Calcite | Level 5

Thanks, that worked. Sorry for posting the image.

ballardw
Super User

@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.

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

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
  • 6 replies
  • 5860 views
  • 4 likes
  • 3 in conversation