DATA Step, Macro, Functions and more

How to assign a flag by sub setting the data based on epoch values when treatment date not available

Reply
Super Contributor
Posts: 272

How to assign a flag by sub setting the data based on epoch values when treatment date not available

Dear,

 

I need assign a base line flag based on wheather or not a treatment date available. Please help

 

For ID=1,  I am able assign baseline flag as trtdate available.

For ID=2, I need to subset all the OBS that have date1 value less than min(date1 value) when epoch=' DOUBLE BLIND WITHDRAWAL'. I can write a simple code to subset the dateset. eg.  "if epoch ^= 'DOUBLE BLIND WITHDRAWAL '   or epoch ^= 'FOLLOW-Up '. Bu this did not help me as there are other EPOCH values and large dataset. So, I need to subset based 'date1' values.

Please help

 

data

 

id             test          date1                   epoch                                                                               trtdate
1            diabp         2016-01-26          SCREENING                                                             24MAR2016
1            diabp         2016-02-24           TITRATION                                                              24MAR2016
1           diabp          2016-03-09            TITRATION                                                             24MAR2016
1          diabp            2016-03-23           STABLE DOSE                                                       24MAR2016
1        diabp             2016-04-05            DOUBLE BLIND WITHDRAWAL                             24MAR2016
1        diabp             2016-04-08           DOUBLE BLIND WITHDRAWAL                               24MAR2016

 

 

id             test          date1                   epoch                                                                               trtdate
2            diabp         2016-01-26          SCREENING                                                            
2            diabp         2016-02-24           TITRATION                                                              
2          diabp          2016-03-09            TITRATION                                                             
2          diabp            2016-03-23           STABLE DOSE                                                     
2        diabp             2016-04-05            DOUBLE BLIND WITHDRAWAL                            
2        diabp             2016-04-08           DOUBLE BLIND WITHDRAWAL                               

2        diabb             2016-05-08           FOLLOW-UP

2        diabb             2016-05-18           FOLLOW-UP

 

 

 

Super User
Posts: 11,343

Re: How to assign a flag by sub setting the data based on epoch values when treatment date not avail

Posted in reply to knveraraju91

I think you may need to provide a bit more information. One thing is to provide an example of what the output should look like.

It isn't clear what type of values the flag should be character or numeric, or what the desired value may be. Also Is this looking for any treatment date at all within an ID or only for some value epoch within id? And what type of subset of Date1? Exactly that date only or within a time frame or?

Super Contributor
Posts: 272

Re: How to assign a flag by sub setting the data based on epoch values when treatment date not avail

Posted in reply to knveraraju91

I am sorry for that insufficient information. I am again including all the information.

 

I need to flag last dose before the start of epoch='DOUBLE BLIND WITHDRAWAL'  dose( trtdate=28MAR2016.)

For ID=1, the output needed is BASEFL='Y' for 4 th OBS. as it is last test  with (date1=2016-03-23)  before 28MAR2016.

 

For ID=2, since the trtdate is not avialable, first I need to subset all the OBS with 'date1' values less than date1 values when epoch='DOUBLE BLIND WITHDRAWAL'.  I need to subset first four OBS for ID=2, and then flag the last dose.

The output needed is BASEFL='Y' for 4 th OBS for ID=2

Thanks you very much for your time.

 

data

 

id             test          date1                   epoch                                                                               trtdate
1            diabp         2016-01-26          SCREENING                                                             20FEB2016
1            diabp         2016-02-24           TITRATION                                                              20MAR2016
1           diabp          2016-03-09            TITRATION                                                             20MAR2016
1          diabp            2016-03-23           STABLE DOSE                                                       22MAR2016
1        diabp             2016-04-05            DOUBLE BLIND WITHDRAWAL                             28MAR2016
1        diabp             2016-04-08           DOUBLE BLIND WITHDRAWAL                              28APR2016

 

 

id             test          date1                   epoch                                                                               trtdate
2            diabp         2016-01-26          SCREENING                                                            
2            diabp         2016-02-24           TITRATION                                                              
2          diabp          2016-03-09            TITRATION                                                             
2          diabp            2016-03-23           STABLE DOSE                                                     
2        diabp             2016-04-05            DOUBLE BLIND WITHDRAWAL                            
2        diabp             2016-04-08           DOUBLE BLIND WITHDRAWAL                               

2        diabb             2016-05-08           FOLLOW-UP

2        diabb             2016-05-18           FOLLOW-UP

 

Super User
Posts: 11,343

Re: How to assign a flag by sub setting the data based on epoch values when treatment date not avail

Posted in reply to knveraraju91

knveraraju91 wrote:

I am sorry for that insufficient information. I am again including all the information.

 

I need to flag last dose before the start of epoch='DOUBLE BLIND WITHDRAWAL'  dose( trtdate=28MAR2016.)

For ID=1, the output needed is BASEFL='Y' for 4 th OBS. as it is last test  with (date1=2016-03-23)  before 28MAR2016.

 

For ID=2, since the trtdate is not avialable, first I need to subset all the OBS with 'date1' values less than date1 values when epoch='DOUBLE BLIND WITHDRAWAL'.  I need to subset first four OBS for ID=2, and then flag the last dose.

The output needed is BASEFL='Y' for 4 th OBS for ID=2

Thanks you very much for your time.


What happens when the value epoch='DOUBLE BLIND WITHDRAWAL' never occurs for a specific ID?

What if there are not 4 dates before the epoch='DOUBLE BLIND WITHDRAWAL'?

Is it always exactly 4 dates? What if epoch='DOUBLE BLIND WITHDRAWAL' does not occur until the 7th record for an Id?

 

I actually am not seeing where TRDATE has anything to do with the rules. It looks like the value of Epoch is the only thing considered.

 

Ask a Question
Discussion stats
  • 3 replies
  • 244 views
  • 0 likes
  • 2 in conversation