BookmarkSubscribeRSS Feed
Astounding
PROC Star

You're still asking macro language to do something it can't.  It can't inspect the data, and adjust the program in the middle of the same DATA step.  But the DATA step can do that.  Here's the idea for one set of variables, where vars=X1 X2 X3 X4 that are assumed to be numeric just to simplify the initial version of the program.

 

data want;

set have;

array test1 {*} &vars;

if max(of test1{*}) = min(of test1{*}) then output;

run;

 

The MIN and MAX functions ignore missing values, thus the IF/THEN statement automatically checks whether all nonmissing values are equal.  That might still be problematic since there might be only one nonmissing value remaining ... you would have to decide what is the right action in that case.  Do we still need to jump through hoops for sets of numeric variables?  

 

If this looks like it doesn't do the right thing, why not?  If this looks like a satisfactory result, we can talk about how to handle sets of character variables.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 15 replies
  • 3713 views
  • 0 likes
  • 5 in conversation