BookmarkSubscribeRSS Feed
SSK_011523
Calcite | Level 5

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 - 

IDLine of treatmentregimen
11LRadiation
12LRadiation
13LRadiation
14LNo subsequent line
15LNo subsequent line
16LNo subsequent line
21LRadiation
22LRCHOP/CHOP-based
23LChemo monotherapy
24LNo subsequent line
25LNo subsequent line
26LNo subsequent line
31Lradiation
32LRadiation
33LRadiation
34LNo subsequent line
35LNo subsequent line
36LNo subsequent line
41LRadiation
42LOther chemotherapy
43LNo subsequent line
44LNo subsequent line
45LNo subsequent line
46LNo subsequent line
51LRadiation
52LBR-based
53LRadiation
51Ltargeted
52LOther chemotherapy
53Ltargeted
54LRadiation
55LRadiation
56LRadiation
2 REPLIES 2
Patrick
Opal | Level 21

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;

Patrick_0-1712722878910.png

 

 

 

ballardw
Super User

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

 

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
  • 2 replies
  • 228 views
  • 0 likes
  • 3 in conversation