Hello !!
Here, I'm trying to do two things -
1) Cohort 1 - I am interested in patients who have some treatment received after radiation (that is observation 2,4,5).
2) Cohort 2 - Patients who have received at least two line of treatment before radiation (observation 5)
Data I have -
ID | Line of treatment | regimen |
1 | 1L | Radiation |
1 | 2L | Radiation |
1 | 3L | Radiation |
1 | 4L | No subsequent line |
1 | 5L | No subsequent line |
1 | 6L | No subsequent line |
2 | 1L | Radiation |
2 | 2L | RCHOP/CHOP-based |
2 | 3L | Chemo monotherapy |
2 | 4L | No subsequent line |
2 | 5L | No subsequent line |
2 | 6L | No subsequent line |
3 | 1L | radiation |
3 | 2L | Radiation |
3 | 3L | Radiation |
3 | 4L | No subsequent line |
3 | 5L | No subsequent line |
3 | 6L | No subsequent line |
4 | 1L | Radiation |
4 | 2L | Other chemotherapy |
4 | 3L | No subsequent line |
4 | 4L | No subsequent line |
4 | 5L | No subsequent line |
4 | 6L | No subsequent line |
5 | 1L | Radiation |
5 | 2L | BR-based |
5 | 3L | Radiation |
5 | 1L | targeted |
5 | 2L | Other chemotherapy |
5 | 3L | targeted |
5 | 4L | Radiation |
5 | 5L | Radiation |
5 | 6L | Radiation |
For next time:
What have you tried so far? By showing us some of your code even if not fully working we can better understand where you are coming from and better provide suitable answers.
Please also provide sample data ready made via SAS data step/datalines code as done below for data have so the ones helping you don't need to first spend time preparing sample data.
data have;
infile datalines truncover dsd;
input ID Line_of_treatment:$2. regimen $40.;
datalines;
1,1L,Radiation
1,2L,Radiation
1,3L,Radiation
1,4L,No subsequent line
1,5L,No subsequent line
1,6L,No subsequent line
2,1L,Radiation
2,2L,RCHOP/CHOP-based
2,3L,Chemo monotherapy
2,4L,No subsequent line
2,5L,No subsequent line
2,6L,No subsequent line
3,1L,radiation
3,2L,Radiation
3,3L,Radiation
3,4L,No subsequent line
3,5L,No subsequent line
3,6L,No subsequent line
4,1L,Radiation
4,2L,Other chemotherapy
4,3L,No subsequent line
4,4L,No subsequent line
4,5L,No subsequent line
4,6L,No subsequent line
5,1L,Radiation
5,2L,BR-based
5,3L,Radiation
5,1L,targeted
5,2L,Other chemotherapy
5,3L,targeted
5,4L,Radiation
5,5L,Radiation
5,6L,Radiation
;
proc sort data=have out=inter;
by id Line_of_treatment;
run;
data want(keep=id cohort_flg_:);
set inter;
by id Line_of_treatment;
retain radiation_cnt other_treatment_cnt cohort_flg_1 cohort_flg_2;
if upcase(regimen) ne 'NO SUBSEQUENT LINE' then
do;
if upcase(regimen)='RADIATION' then
do;
radiation_cnt+1;
if other_treatment_cnt>1 then cohort_flg_2=1;
end;
else
do;
other_treatment_cnt+1;
if radiation_cnt>0 then cohort_flg_1=1;
end;
end;
if last.id then
do;
output;
call missing(radiation_cnt, other_treatment_cnt, cohort_flg_1, cohort_flg_2);
end;
run;
proc print data=want;
run;
Please refer to variable names, such as ID. I had to seriously reread your text multiple times to figure out that by "observation" you actually mean "values of the ID variable".
Observation is typically used in SAS discussions about the single set of values on a record or "line number". I spent a lot of time trying to find how "observation 2,4,5" met your discussion because observation 2, in SAS terms, has a regimen value of radiation.
@SSK_011523 wrote:
Hello !!
Here, I'm trying to do two things -
1) Cohort 1 - I am interested in patients who have some treatment received after radiation (that is observation 2,4,5).
2) Cohort 2 - Patients who have received at least two line of treatment before radiation (observation 5)
Data I have -
ID Line of treatment regimen 1 1L Radiation 1 2L Radiation 1 3L Radiation 1 4L No subsequent line 1 5L No subsequent line 1 6L No subsequent line 2 1L Radiation 2 2L RCHOP/CHOP-based 2 3L Chemo monotherapy 2 4L No subsequent line 2 5L No subsequent line 2 6L No subsequent line 3 1L radiation 3 2L Radiation 3 3L Radiation 3 4L No subsequent line 3 5L No subsequent line 3 6L No subsequent line 4 1L Radiation 4 2L Other chemotherapy 4 3L No subsequent line 4 4L No subsequent line 4 5L No subsequent line 4 6L No subsequent line 5 1L Radiation 5 2L BR-based 5 3L Radiation 5 1L targeted 5 2L Other chemotherapy 5 3L targeted 5 4L Radiation 5 5L Radiation 5 6L Radiation
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.
Ready to level-up your skills? Choose your own adventure.