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

Hello,

 

I have to derive aval based on conditional strategies.

 

"in the following order of priority:
1) Check "SWREL". If aval eq 1: Composite strategy 2 using "EASITOTA" as the source score
if swrel = 1  then flg currently will be 'Composite Strategy 2'.  if swrel = 0 for all records per subject flag will be blank at this stage


2) Check "RTT1L28D” and “TCM2”. If aval eq 1: Composite strategy 1 using "EASITOTA" as the source score

if either tcm2 or rtt1l28 = 1 along with swrel = 1 then flg will change from "Composite Strategy 2 " to  "Composite Strategy 1" .

If swrel,rtt1l28,tcm2 all = 0 for all records per subject then flag will be blank at this stage


2) Check "SWNREL" aval eq 1: While-on-Treatment strategy.

if swnrel = 1   and tcm2 or rtt1l28= 1 then flg  will be 'While-on-Treatment'.

3) Apply treatment policy strategy – use data as collected in “EASITOTA”"

If swrel,rtt1l28,tcm2,swnrel all = 0 for all records per subject then flag will be 'treatment policy'

 

 

Programming logic
"1)If AVAL = 1 for  "SWREL" , apply Composite strategy 2 using "EASITOTA" aval. 2) If AVAL equals 1 on either record where  "RTT1L28D" or "T2CM", apply Composite strategy 1 using "EASITOTA" aval. 3) If SWNREL equals 1 on the record,  apply While-on-Treatment strategy. 4) Apply Treatment Policy strategy using "EASITOTA" aval."

 

Here is the data in it's merged form with all relevant variables. For context the aval for SWREL, SWNREL, TCM2  and RTT1L28 represent intercurrent events and the score (AVAL)  was transposed to the EASITOTA  dataset and a value of 1 indicates an intercurrent event occurred and a value of 0 indicates no intercurrent event.

 

data have;
input  PARAMCD $ SUBJID $ AVISITN :8. ADT :$9. AVAL :8. RTT1L28D :8. T2CM :8. SWREL :8.  SWNREL :8.;
infile datalines dlm = '|';
datalines;
EASITOTA|1001|20|27APR2022|13.4|0|0|0|0
EASITOTA|1001|30|11MAY2022|13.4|0|0|0|0
EASITOTA|1001|40|26MAY2022|13.4|0|0|0|0
EASITOTA|1001|50|22JUN2022|13.4|0|0|0|0
EASITOTA|1001|60|20JUL2022|13.4|0|0|0|0
EASITOTA|1001|70|31AUG2022|13.4|0|0|0|0
EASITOTA|1002|20|27APR2022|16.4|0|0|0|0
EASITOTA|1002|30|11MAY2022|16.4|0|0|0|0
EASITOTA|1002|40|25MAY2022|16.4|1|0|0|0
EASITOTA|1002|50|22JUN2022|16.4|1|0|0|0
EASITOTA|1002|60|20JUL2022|16.4|1|0|0|0
EASITOTA|1002|70|22AUG2022|16.4|1|0|0|0
EASITOTA|1003|20|07JUN2022|15.8|0|0|1|0
EASITOTA|1003|20|21JUN2022|15.8|1|0|1|0
EASITOTA|1003|30|05JUL2022|15.8|1|0|1|0
EASITOTA|1003|40|02AUG2022|15.8|0|0|1|0
EASITOTA|1003|50|30AUG2022|15.8|0|0|1|0
EASITOTA|1003|60|27SEP2022|15.8|0|0|1|0
EASITOTA|1003|70|25OCT2022|15.8|0|0|1|0

;
run;

Basically I would like to create a flag that assigns the correct strategy to all records per subject so I can further go on to derive aval (based on these strategies below). I was thinking that a conditional dow loop may work here but if there is a simpler approach I would really appreciate it.

 

smackerz1988_0-1666276222443.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Onyx | Level 15

Do you mean something like this:

data have;
input  PARAMCD $ SUBJID $ AVISITN :8. ADT :$9. AVAL :8. RTT1L28D :8. T2CM :8. SWREL :8.  SWNREL :8.;
infile datalines dlm = '|';
datalines;
EASITOTA|1001|20|27APR2022|13.4|0|0|0|0
EASITOTA|1001|30|11MAY2022|13.4|0|0|0|0
EASITOTA|1001|40|26MAY2022|13.4|0|0|0|0
EASITOTA|1001|50|22JUN2022|13.4|0|0|0|0
EASITOTA|1001|60|20JUL2022|13.4|0|0|0|0
EASITOTA|1001|70|31AUG2022|13.4|0|0|0|0
EASITOTA|1002|20|27APR2022|16.4|0|0|0|0
EASITOTA|1002|30|11MAY2022|16.4|0|0|0|0
EASITOTA|1002|40|25MAY2022|1   |1|0|0|0
EASITOTA|1002|50|22JUN2022|16.4|1|0|0|0
EASITOTA|1002|60|20JUL2022|16.4|1|0|0|0
EASITOTA|1002|70|22AUG2022|16.4|1|0|0|0
EASITOTA|1003|20|07JUN2022|15.8|0|0|1|0
EASITOTA|1003|20|21JUN2022|15.8|1|0|1|0
EASITOTA|1003|30|05JUL2022|15.8|1|0|1|0
EASITOTA|1003|40|02AUG2022|15.8|0|0|1|0
EASITOTA|1003|50|30AUG2022|1   |0|0|1|0
EASITOTA|1003|60|27SEP2022|15.8|0|0|1|0
EASITOTA|1003|70|25OCT2022|15.8|0|0|1|0

;
run;
proc print; run;
/* 1) If AVAL = 1 for "SWREL" , apply Composite strategy 2 using "EASITOTA" aval. 2) If AVAL equals 1 on either record where "RTT1L28D" or "T2CM", apply Composite strategy 1 using "EASITOTA" aval. 3) If SWNREL equals 1 on the record, apply While-on-Treatment strategy. 4) Apply Treatment Policy strategy using "EASITOTA" aval. */ proc format; value strategy 1 = "Composite strategy 2" 2 = "Composite strategy 1" 3 = "While-on-Treatment strategy" 4 = "Treatment Policy strategy" other = "ERROR" ; run; data want; format strategy strategy.; do _N_ = 1 by 1 until(last.SUBJID); set have; by SUBJID; select; when (AVAL = 1 and SWREL) row_st = 1; when (AVAL = 1 and (RTT1L28D or T2CM)) row_st = 2; when (SWNREL) row_st = 3; otherwise row_st = 4; end; strategy = min(strategy,row_st); end; do _N_ = 1 to _N_; set have; output; end; run; proc print; run;

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

5 REPLIES 5
ballardw
Super User

I have to say that I cannot follow what is intended by any of priorities 1 through 4.

Examples of interpretation:

What are we checking SWREL for what/how and what indication that it has been checked (since this step is apparently needed for the second)? When checking "RTT1L28D” and “TCM2” is that each variable individually or combinations of the two, for what and how to indicate "checked"?

What is a "Composite Strategy"? What variables are involved and how?

What is a "source score"? How is it used? what variables?

What is an "intercurrent event"? Variables and values needed to tell what one is?

What is "While-on treatment strategy"? Variables and values to use?

How to apply a "treatment policy strategy"?

 

And what exactly does "if no changes to data in step 1" mean? For specific records? Specific value combinations of some variables? The entire data set?

 

 

You may have to talk us through some specific examples. These priorities are a pretty good example of very specific to one field jargon and need translation to anyone working outside of that field and possibly your organization. So clear definitions and expected results at each step are needed.

smackerz1988
Pyrite | Level 9

What are we checking SWREL for what/how and what indication that it has been checked (since this step is apparently needed for the second)?

SWREL is an intercurrent event and a value of 1 represents it occured and 0 it didn't

 

When checking "RTT1L28D” and “TCM2” is that each variable individually or combinations of the two, for what and how to indicate "checked"?

that either has a value of 1 or 0

 

What is a "Composite Strategy"? What variables are involved and how?

Not needed. It is what I'll be using to derive aval but would like a flag to indicate which strategy per subject I use based on the iterative ranking process

 

What is a "source score"? How is it used? what variables?

synonym for AVAL column

What is an "intercurrent event"? Variables and values needed to tell what one is?

Updated post to give as much information as needed

 

What is "While-on treatment strategy"? Variables and values to use?

same idea as composite strategy. will be a term for the flag value

 

How to apply a "treatment policy strategy"?

same idea as composite strategy. will be a term for the flag value

 

And what exactly does "if no changes to data in step 1" mean? For specific records? Specific value combinations of some variables? The entire data set?

All records per subject

yabwon
Onyx | Level 15

Do you mean something like this:

data have;
input  PARAMCD $ SUBJID $ AVISITN :8. ADT :$9. AVAL :8. RTT1L28D :8. T2CM :8. SWREL :8.  SWNREL :8.;
infile datalines dlm = '|';
datalines;
EASITOTA|1001|20|27APR2022|13.4|0|0|0|0
EASITOTA|1001|30|11MAY2022|13.4|0|0|0|0
EASITOTA|1001|40|26MAY2022|13.4|0|0|0|0
EASITOTA|1001|50|22JUN2022|13.4|0|0|0|0
EASITOTA|1001|60|20JUL2022|13.4|0|0|0|0
EASITOTA|1001|70|31AUG2022|13.4|0|0|0|0
EASITOTA|1002|20|27APR2022|16.4|0|0|0|0
EASITOTA|1002|30|11MAY2022|16.4|0|0|0|0
EASITOTA|1002|40|25MAY2022|1   |1|0|0|0
EASITOTA|1002|50|22JUN2022|16.4|1|0|0|0
EASITOTA|1002|60|20JUL2022|16.4|1|0|0|0
EASITOTA|1002|70|22AUG2022|16.4|1|0|0|0
EASITOTA|1003|20|07JUN2022|15.8|0|0|1|0
EASITOTA|1003|20|21JUN2022|15.8|1|0|1|0
EASITOTA|1003|30|05JUL2022|15.8|1|0|1|0
EASITOTA|1003|40|02AUG2022|15.8|0|0|1|0
EASITOTA|1003|50|30AUG2022|1   |0|0|1|0
EASITOTA|1003|60|27SEP2022|15.8|0|0|1|0
EASITOTA|1003|70|25OCT2022|15.8|0|0|1|0

;
run;
proc print; run;
/* 1) If AVAL = 1 for "SWREL" , apply Composite strategy 2 using "EASITOTA" aval. 2) If AVAL equals 1 on either record where "RTT1L28D" or "T2CM", apply Composite strategy 1 using "EASITOTA" aval. 3) If SWNREL equals 1 on the record, apply While-on-Treatment strategy. 4) Apply Treatment Policy strategy using "EASITOTA" aval. */ proc format; value strategy 1 = "Composite strategy 2" 2 = "Composite strategy 1" 3 = "While-on-Treatment strategy" 4 = "Treatment Policy strategy" other = "ERROR" ; run; data want; format strategy strategy.; do _N_ = 1 by 1 until(last.SUBJID); set have; by SUBJID; select; when (AVAL = 1 and SWREL) row_st = 1; when (AVAL = 1 and (RTT1L28D or T2CM)) row_st = 2; when (SWNREL) row_st = 3; otherwise row_st = 4; end; strategy = min(strategy,row_st); end; do _N_ = 1 to _N_; set have; output; end; run; proc print; run;

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



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
  • 5 replies
  • 615 views
  • 3 likes
  • 3 in conversation