BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Astounding
PROC Star

It's not at all clear what you mean by "separately".  Do you want multiple output data sets?

 

What should happen to an observation when SCORE1 is in range and SCORE2 is out of range?

_maldini_
Barite | Level 11

@Astounding 

 

<It's not at all clear what you mean by "separately".>

Sorry. I see your confusion. I mean "independently". 

 

"And then independently, I want all the values of score2 included if they are between the same parameters for score2, etc.."

 

<Do you want multiple output data sets?>

 

No, I want one dataset.

 

<What should happen to an observation when SCORE1 is in range and SCORE2 is out of range?>

 

If score1 is in range, it should be output to the dataset. If score2 is out of range it should not. The final dataset should only include those values that meet the BETWEEN...AND...criteria.

Astounding
PROC Star

In a SAS data set, I don't think that's one of your possible choices.  When you output an observation, all the variables are output.  You can't change that from one observation to the next.

 

There are other things you can do.  You can set out of range values to missing before you output.  Or you can totally re-shape the data set along these lines:

 

ID   Score_variable score_value

ABC  score1                  25

ABC  score2                  30

DEF  score2                  40

 

But there is no way to change the variables that get output from one observation to the next.

_maldini_
Barite | Level 11

@Reeza @Reeza @PGStats

 

Thanks for all your help. I think the limitation is my understading of SAS! 

 

I'm just going to output to different datasets....

Reeza
Super User

Your observations are not independent the way your thinking of them. If both conditions are true which takes precedence? 

 

I think you need to post sample data and expected output at this point to clarify your requirement. 

 

 

ChrisNZ
Tourmaline | Level 20

It's just a slightly different syntax. I think you want to replace

 

DATA want; 
	SET have;
 		WHERE score1 BETWEEN (1.5*Q3_score1) AND (Q1_score1/1.5);
 		WHERE SAME AND score2 BETWEEN (1.5*Q3_score2) AND (Q1_score2/1.5);
 		WHERE SAME AND score3 BETWEEN (1.5*Q3_score3) AND (Q1_score3/1.5);
	RUN;

with

 

DATA want; 
	SET have;
 		WHERE      score1 BETWEEN (1.5*Q3_score1) AND (Q1_score1/1.5);
 		WHERE ALSO score2 BETWEEN (1.5*Q3_score2) AND (Q1_score2/1.5);
 		WHERE ALSO score3 BETWEEN (1.5*Q3_score3) AND (Q1_score3/1.5);
	RUN;

otherwise the last where statement replaces the previous ones.

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 20 replies
  • 38623 views
  • 12 likes
  • 5 in conversation