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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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