BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
SAS_Novice22
Quartz | Level 8

Hi SAS Experts,

I am trying to evaluate inclusion/exclusion criteria for a study and the way my data is set up requires me to take a number of steps to get at what I would like.

 

I ultimately want to know who is eligible (i.e., they met the 2 inclusion criteria and did not meet any of the 3 exclusion criteria). Each criteria is its own variable. 

 

I feel my SAS code is solid in getting at what I want however, my problem occurs early on in that the variables I am attempting to generate keep getting written over. What am I doing wrong? Here is my SAS code below:

/**Eligibility Part B Inclusion Criteria**/

DATA WORK.IEB2;
	SET IEB;
	INCLU1_YES = .;
	INCLU2_YES = .;
RUN;

/**Eligibility Part B - INCLUSION #1**/

DATA WORK.IEB2;
	SET IEB;
	IF IC01R_DEC="Yes" OR IC01L_DEC="Yes" THEN INCLU1_YES=1;
	ELSE INCLU1_YES = 0;
RUN;

/**Eligibility Part B - INCLUSION #2**/
DATA WORK.IEB2;
	SET IEB;
	IF IC02R_DEC="Yes" OR IC02L_DEC="Yes" THEN INCLU2_YES=1;
	ELSE INCLU2_YES = 0;
RUN;

DATA WORK.IEB2;
	SET IEB;
	IF INCLU1_YES=1 AND INCLU2_YES=1 THEN INCLUSION_YES=1;
	ELSE INCLUSION_YES = 0;
RUN;

TITLE "Eligibility Part 2 - Count of how many met/did not meet inclusion criteria Overall"; 
PROC FREQ DATA=WORK.IEB2;
	TABLES OVERALL*ELIG_YES;
RUN;

/**Eligibility Part B Exclusion Criteria**/
DATA WORK.IEB2;
	SET IEB;
	EXCLU1_YES = .;
	EXCLU2_YES = .;
	EXCLU3_YES = .;
RUN;

/**Eligibility Part B - EXCLUSION #1**/
DATA WORK.IEB2;
	SET IEB;
	IF EX01R_DEC="Yes" OR EX01L_DEC="Yes" THEN EXCLU1_YES=1;
	ELSE EXCLU1_YES = 0;
RUN;

/**Eligibility Part B - EXCLUSION #2**/
DATA WORK.IEB2;
	SET IEB;
	IF EX02R_DEC="Yes" OR EX02L_DEC="Yes" THEN EXCLU2_YES=1;
	ELSE EXCLU2_YES = 0;
RUN;

/**Eligibility Part B - EXCLUSION #3**/
DATA WORK.IEB2;
	SET IEB;
	IF EX03_DEC="Yes" THEN EXCLU3_YES=1;
	ELSE EXCLU3_YES = 0;
RUN;

DATA WORK.IEB2;
	SET IEB;
	IF EXCLU1_YES=1 OR EXCLU2_YES=1 OR EXCLU3_YES=1 THEN EXCLUDED_YES=1;
	ELSE EXCLUDED_YES = 0;
RUN;

TITLE "Eligibility Part 2 - Count of how many were excluded due to exclusion criteria Overall"; 
PROC FREQ DATA=WORK.IEB2;
	TABLES OVERALL*EXCLUDED_YES;
RUN;

DATA WORK.IEB2;
	SET IEB;
	IF INCLUSION_YES=1 AND EXCLUDED_YES=0 THEN ELIG_YES=1;
	ELSE ELIG_YES = 0;
RUN;

I am not getting any SAS error messages - but the problem is occuring when I attempt to generate and reclassify the following variables.

DATA WORK.IEB2;
	SET IEB;
	EXCLU1_YES = .;
	EXCLU2_YES = .;
	EXCLU3_YES = .;
RUN;

Any help would be greatly appreciated.

 

Thank you,

T.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
DATA WORK.IEB2;
	SET IEB;
       *not needed;
	INCLU1_YES = .;
	INCLU2_YES = .;


/**Eligibility Part B - INCLUSION #1**/

	IF IC01R_DEC="Yes" OR IC01L_DEC="Yes" THEN INCLU1_YES=1;
	ELSE INCLU1_YES = 0;

/**Eligibility Part B - INCLUSION #2**/

	IF IC02R_DEC="Yes" OR IC02L_DEC="Yes" THEN INCLU2_YES=1;
	ELSE INCLU2_YES = 0;



	IF INCLU1_YES=1 AND INCLU2_YES=1 THEN INCLUSION_YES=1;
	ELSE INCLUSION_YES = 0;

RUN;

TITLE "Eligibility Part 2 - Count of how many met/did not meet inclusion criteria Overall"; 
PROC FREQ DATA=WORK.IEB2;
	TABLES OVERALL*ELIG_YES;
RUN;

/**Eligibility Part B Exclusion Criteria**/
DATA WORK.IEB3;
	SET IEB2;
	EXCLU1_YES = .;
	EXCLU2_YES = .;
	EXCLU3_YES = .;


/**Eligibility Part B - EXCLUSION #1**/

	IF EX01R_DEC="Yes" OR EX01L_DEC="Yes" THEN EXCLU1_YES=1;
	ELSE EXCLU1_YES = 0;


/**Eligibility Part B - EXCLUSION #2**/

	IF EX02R_DEC="Yes" OR EX02L_DEC="Yes" THEN EXCLU2_YES=1;
	ELSE EXCLU2_YES = 0;


/**Eligibility Part B - EXCLUSION #3**/

	IF EX03_DEC="Yes" THEN EXCLU3_YES=1;
	ELSE EXCLU3_YES = 0;

	IF EXCLU1_YES=1 OR EXCLU2_YES=1 OR EXCLU3_YES=1 THEN EXCLUDED_YES=1;
	ELSE EXCLUDED_YES = 0;
RUN;

TITLE "Eligibility Part 2 - Count of how many were excluded due to exclusion criteria Overall"; 
PROC FREQ DATA=WORK.IEB3;
	TABLES OVERALL*EXCLUDED_YES;
RUN;

DATA WORK.IEB4;
	SET IEB3;
	IF INCLUSION_YES=1 AND EXCLUDED_YES=0 THEN ELIG_YES=1;
	ELSE ELIG_YES = 0;
RUN;

Pay more attention to your INPUT and OUTPUT data set name and how the flow. If you track them throughout the process you should be able to see the errors. 

 

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

Why do you keep sourcing the original dataset instead of the modified dataset?

Your first step is reading from IEB to create IEB2.

Your second step is reading from IEB to re-create IEB2 (removing the version made in the previous step).

 

Why not just re-write the steps to take IEB and generate IEB2 and then take IEB2 and generate IEB3 etc untill you get what you want?

 

SAS_Novice22
Quartz | Level 8
Thank you, that is exactly what I was doing wrong! 🙂
T.
Reeza
Super User
DATA WORK.IEB2;
	SET IEB;
       *not needed;
	INCLU1_YES = .;
	INCLU2_YES = .;


/**Eligibility Part B - INCLUSION #1**/

	IF IC01R_DEC="Yes" OR IC01L_DEC="Yes" THEN INCLU1_YES=1;
	ELSE INCLU1_YES = 0;

/**Eligibility Part B - INCLUSION #2**/

	IF IC02R_DEC="Yes" OR IC02L_DEC="Yes" THEN INCLU2_YES=1;
	ELSE INCLU2_YES = 0;



	IF INCLU1_YES=1 AND INCLU2_YES=1 THEN INCLUSION_YES=1;
	ELSE INCLUSION_YES = 0;

RUN;

TITLE "Eligibility Part 2 - Count of how many met/did not meet inclusion criteria Overall"; 
PROC FREQ DATA=WORK.IEB2;
	TABLES OVERALL*ELIG_YES;
RUN;

/**Eligibility Part B Exclusion Criteria**/
DATA WORK.IEB3;
	SET IEB2;
	EXCLU1_YES = .;
	EXCLU2_YES = .;
	EXCLU3_YES = .;


/**Eligibility Part B - EXCLUSION #1**/

	IF EX01R_DEC="Yes" OR EX01L_DEC="Yes" THEN EXCLU1_YES=1;
	ELSE EXCLU1_YES = 0;


/**Eligibility Part B - EXCLUSION #2**/

	IF EX02R_DEC="Yes" OR EX02L_DEC="Yes" THEN EXCLU2_YES=1;
	ELSE EXCLU2_YES = 0;


/**Eligibility Part B - EXCLUSION #3**/

	IF EX03_DEC="Yes" THEN EXCLU3_YES=1;
	ELSE EXCLU3_YES = 0;

	IF EXCLU1_YES=1 OR EXCLU2_YES=1 OR EXCLU3_YES=1 THEN EXCLUDED_YES=1;
	ELSE EXCLUDED_YES = 0;
RUN;

TITLE "Eligibility Part 2 - Count of how many were excluded due to exclusion criteria Overall"; 
PROC FREQ DATA=WORK.IEB3;
	TABLES OVERALL*EXCLUDED_YES;
RUN;

DATA WORK.IEB4;
	SET IEB3;
	IF INCLUSION_YES=1 AND EXCLUDED_YES=0 THEN ELIG_YES=1;
	ELSE ELIG_YES = 0;
RUN;

Pay more attention to your INPUT and OUTPUT data set name and how the flow. If you track them throughout the process you should be able to see the errors. 

 

SAS_Novice22
Quartz | Level 8
Thank you, that is exactly what I was doing! 🙂
T.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 452 views
  • 2 likes
  • 3 in conversation