<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Alternative code with easy understading in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783550#M249862</link>
    <description>&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for help.&lt;/P&gt;&lt;P&gt;I have try te get some sammple data here and expalined rules and output.&lt;/P&gt;&lt;P&gt;Plese help me code with differently previosu code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data ce;
input usubjid :$40 ceterm :$200 cestdtc :yymmdd10.;
format cestdtc yymmdd10.;
datalines;
D169CC00001/E0201004    CV DEATH    14-09-21
D169CC00001/E0201004    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    04-02-20
D169CC00001/E0201004    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    03-09-21
D169CC00001/E0201004    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    04-02-20
D169CC00001/E0201007    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    20-05-21
D169CC00001/E0201025    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    04-06-20
D169CC00001/E0201025    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    04-06-20
;
run;

data se;
input usubjid :$40 EPOCH :$200 SESTDTC :yymmdd10. SEENDTC :yymmdd10.;
format SESTDTC SEENDTC yymmdd10.;
datalines;
USUBJID	EPOCH	SESTDTC	SEENDTC
D169CC00001/E0201004    SCREENING	        07-02-19	12-02-19
D169CC00001/E0201004	BLINDED TREATMENT	12-02-19	15-09-21
D169CC00001/E0201007	SCREENING	        01-04-19	08-04-19
D169CC00001/E0201007	BLINDED TREATMENT	08-04-19	 
D169CC00001/E0205038	SCREENING	        12-09-19	19-09-19
D169CC00001/E0205038	BLINDED TREATMENT	19-09-19	20-02-20
D169CC00001/E0205038	FOLLOW-UP	        20-02-20	 
D169CC00001/E0201025	SCREENING	        26-09-19	03-10-19
D169CC00001/E0201025	BLINDED TREATMENT	03-10-19	08-01-20
D169CC00001/E0201025	FOLLOW-UP	        08-01-20
;
run;

/* From Above two data set are left joined by below code. */
/*before left join created one unique id in CE data */
/*for final output records same as first CE data */

data ce;
  set ce;
  seq_id=_n_;
run;

proc sql;
 create table ce_and_se as
 select a.*,b.epoch,b.sestdtc,b.seendtc
 from ce as a left join se as before on a.usubjid=b.usubjid;
quit;

Output data set as below:
1. Output data set have same observation from first CE data.
2. EPOCH values will be assinged based on date when SESTDTC &amp;lt;= cestdtc &amp;lt; SEENDTC.
3. if cestdtc is missing then epoch will missing values.
4. if  SESTDTC &amp;lt;= cestdtc &amp;lt; SEENDTC this logic not fall then print those values to log (only when cestdtc and SESTDTC and SEENDTC not missing)

/*Final output like below:*/
/*data have */
USUBJID	ceterm	cestdtc	EPOCH
D169CC00001/E0201004	CV DEATH	14-09-21	
D169CC00001/E0201004	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	04-02-20	BLINDED TREATMENT
D169CC00001/E0201004	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	03-09-21	BLINDED TREATMENT
D169CC00001/E0201004	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	04-02-20	BLINDED TREATMENT
D169CC00001/E0201007	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	20-05-21	BLINDED TREATMENT
D169CC00001/E0201025	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	04-06-20	FOLLOW-UP
D169CC00001/E0201025	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	04-06-20	FOLLOW-UP







&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 02 Dec 2021 07:17:17 GMT</pubDate>
    <dc:creator>raja777pharma</dc:creator>
    <dc:date>2021-12-02T07:17:17Z</dc:date>
    <item>
      <title>Alternative code with easy understading</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783239#M249696</link>
      <description>&lt;P&gt;Hello ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am unable to understand how below code is working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can any one alternative code will provide with easy understand with same logic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data ss3_epoch_6;
   set epoch2;
   by seq_id usubjid strvard sestd seend;
   retain outfl;
   if first.seq_id then outfl = 0;
   
   if strvard &amp;gt;= sestd and seend &amp;gt; strvard and sestd ne . and strvard ne . and outfl = 0 then do;
       output;
       outfl = 1;
   end;
   * If strtvar does not fit any epoch, set it to missing and output;
   if last.seq_id and outfl = 0 then do;
   * Fix for ongoing study where the end date for the last epoch is still missing.;
   if seend = . and strvard ne . then output;
   else do;
   EPOCH = "";
   if strvard ne . then PUTLOG "(epoch) STAR_CHECK: Provided date outside all epochs in sdtm.SE for subject: " 
USUBJID= N=;
   output;
  end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Rajasekhar.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 18:26:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783239#M249696</guid>
      <dc:creator>raja777pharma</dc:creator>
      <dc:date>2021-11-30T18:26:57Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative code with easy understading</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783247#M249702</link>
      <description>&lt;P&gt;For every seq_id, the first observation that meets this condition&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;strvard &amp;gt;= sestd and seend &amp;gt; strvard and sestd ne . and strvard ne . and&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is output; if no such observation is found, the last observation is output, with EPOCH set to a missing value if another condition is met.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 18:47:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783247#M249702</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-11-30T18:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative code with easy understading</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783284#M249719</link>
      <description>&lt;P&gt;I don't see how the code could be simplified.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Better formatting (indentation) might help you to understand the logic.&lt;/P&gt;
&lt;P&gt;I don't know the data, so can't comment further, but the coder did a good job.&lt;/P&gt;
&lt;P&gt;It's your opportunity for growth it seems &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 21:23:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783284#M249719</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-11-30T21:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative code with easy understading</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783370#M249763</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi , Below is example data sorry i am not able to write the data here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="raja777pharma_0-1638356416074.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66303i3D399EB1457E5486/image-size/large?v=v2&amp;amp;px=999" role="button" title="raja777pharma_0-1638356416074.png" alt="raja777pharma_0-1638356416074.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For below code is output two obervations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data out;
set input;
by seq_id usubjid strvard sestd seend;
retain outfl;
   if first.seq_id then outfl = 0;
   
   if strvard &amp;gt;= sestd and seend &amp;gt; strvard and sestd ne . and strvard ne . and outfl = 0 then do;
       output;
       outfl = 1;
   end;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="raja777pharma_1-1638356763619.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66304i6DC4FBB5C3EE981C/image-size/large?v=v2&amp;amp;px=999" role="button" title="raja777pharma_1-1638356763619.png" alt="raja777pharma_1-1638356763619.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrote the same logic but no observations are output with below code , please help me to understand what i am missing , aslo please help to write different from above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data output;
 set input;
by seq_id usubjid strvard sestd seend;
 if first.seq_id then do;       
	    	if sestd ^= . and strvard ^= .  then do;
	      		if sestd &amp;lt;= strvard and  strvard &amp;lt; seend then do;
	      		    flag=1;
	       			output;
	      		end;   		 
            end;
       end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Rajasekhar.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Dec 2021 11:07:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783370#M249763</guid>
      <dc:creator>raja777pharma</dc:creator>
      <dc:date>2021-12-01T11:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative code with easy understading</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783375#M249766</link>
      <description>&lt;P&gt;Post usable data, like tghis:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input seq_id epoch :$20. sestdtc :yymmdd10.;
format sestdtc yymmdd10.;
datalines;
199 SCREENING 2019-09-24
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Add additional variables and observations as needed to illustrate your issue.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Dec 2021 11:51:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783375#M249766</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-12-01T11:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative code with easy understading</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783535#M249852</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;data output;
 set input;
by seq_id usubjid strvard sestd seend;
 if first.seq_id then do;       
	    	if sestd ^= . and strvard ^= .  then do;
	      		if sestd &amp;lt;= strvard and  strvard &amp;lt; seend then do;
	      		    flag=1;
	       			output;
	      		end;   		 
            end;
       end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since you force the &lt;STRONG&gt;output&lt;/STRONG&gt; statement, your code will only output records that match:&lt;/P&gt;
&lt;P&gt;&lt;CODE class=""&gt;&amp;nbsp;first.seq_id and sestd ^= . and strvard ^= .  and sestd &amp;lt;= strvard and  strvard &amp;lt; seend&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that&lt;/P&gt;
&lt;P&gt;&lt;CODE class=""&gt;sestd &amp;lt;= strvard and  strvard &amp;lt; seend&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;can be written&lt;/P&gt;
&lt;P&gt;&lt;CODE class=""&gt;sestd &amp;lt;= strvard &amp;lt; seend&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 04:11:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783535#M249852</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-12-02T04:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative code with easy understading</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783548#M249860</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for help.&lt;/P&gt;&lt;P&gt;I have try te get some sammple data here and expalined rules and output.&lt;/P&gt;&lt;P&gt;Plese help me code with differently previosu code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data ce;
input usubjid :$40 ceterm :$200 cestdtc :yymmdd10.;
format cestdtc yymmdd10.;
datalines;
D169CC00001/E0201004    CV DEATH    14-09-21
D169CC00001/E0201004    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    04-02-20
D169CC00001/E0201004    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    03-09-21
D169CC00001/E0201004    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    04-02-20
D169CC00001/E0201007    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    20-05-21
D169CC00001/E0201025    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    04-06-20
D169CC00001/E0201025    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    04-06-20
;
run;

data se;
input usubjid :$40 EPOCH :$200 SESTDTC :yymmdd10. SEENDTC :yymmdd10.;
format SESTDTC SEENDTC yymmdd10.;
datalines;
USUBJID	EPOCH	SESTDTC	SEENDTC
D169CC00001/E0201004    SCREENING	        07-02-19	12-02-19
D169CC00001/E0201004	BLINDED TREATMENT	12-02-19	15-09-21
D169CC00001/E0201007	SCREENING	        01-04-19	08-04-19
D169CC00001/E0201007	BLINDED TREATMENT	08-04-19	 
D169CC00001/E0205038	SCREENING	        12-09-19	19-09-19
D169CC00001/E0205038	BLINDED TREATMENT	19-09-19	20-02-20
D169CC00001/E0205038	FOLLOW-UP	        20-02-20	 
D169CC00001/E0201025	SCREENING	        26-09-19	03-10-19
D169CC00001/E0201025	BLINDED TREATMENT	03-10-19	08-01-20
D169CC00001/E0201025	FOLLOW-UP	        08-01-20
;
run;

/* From Above two data set are left joined by below code. */
/*before left join created one unique id in CE data */
/*for final output records same as first CE data */

data ce;
  set ce;
  seq_id=_n_;
run;

proc sql;
 create table ce_and_se as
 select a.*,b.epoch,b.sestdtc,b.seendtc
 from ce as a left join se as before on a.usubjid=b.usubjid;
quit;

Output data set as below:
1. Output data set have same observation from first CE data.
2. EPOCH values will be assinged based on date when SESTDTC &amp;lt;= cestdtc &amp;lt; SEENDTC.
3. if cestdtc is missing then epoch will missing values.
4. if  SESTDTC &amp;lt;= cestdtc &amp;lt; SEENDTC this logic not fall then print those values to log (only when cestdtc and SESTDTC and SEENDTC not missing)

/*Final output like below:*/
/*data have */
USUBJID	ceterm	cestdtc	EPOCH
D169CC00001/E0201004	CV DEATH	14-09-21	
D169CC00001/E0201004	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	04-02-20	BLINDED TREATMENT
D169CC00001/E0201004	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	03-09-21	BLINDED TREATMENT
D169CC00001/E0201004	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	04-02-20	BLINDED TREATMENT
D169CC00001/E0201007	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	20-05-21	BLINDED TREATMENT
D169CC00001/E0201025	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	04-06-20	FOLLOW-UP
D169CC00001/E0201025	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	04-06-20	FOLLOW-UP&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;Rajasekhar.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 07:05:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783548#M249860</guid>
      <dc:creator>raja777pharma</dc:creator>
      <dc:date>2021-12-02T07:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative code with easy understading</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783550#M249862</link>
      <description>&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for help.&lt;/P&gt;&lt;P&gt;I have try te get some sammple data here and expalined rules and output.&lt;/P&gt;&lt;P&gt;Plese help me code with differently previosu code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data ce;
input usubjid :$40 ceterm :$200 cestdtc :yymmdd10.;
format cestdtc yymmdd10.;
datalines;
D169CC00001/E0201004    CV DEATH    14-09-21
D169CC00001/E0201004    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    04-02-20
D169CC00001/E0201004    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    03-09-21
D169CC00001/E0201004    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    04-02-20
D169CC00001/E0201007    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    20-05-21
D169CC00001/E0201025    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    04-06-20
D169CC00001/E0201025    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    04-06-20
;
run;

data se;
input usubjid :$40 EPOCH :$200 SESTDTC :yymmdd10. SEENDTC :yymmdd10.;
format SESTDTC SEENDTC yymmdd10.;
datalines;
USUBJID	EPOCH	SESTDTC	SEENDTC
D169CC00001/E0201004    SCREENING	        07-02-19	12-02-19
D169CC00001/E0201004	BLINDED TREATMENT	12-02-19	15-09-21
D169CC00001/E0201007	SCREENING	        01-04-19	08-04-19
D169CC00001/E0201007	BLINDED TREATMENT	08-04-19	 
D169CC00001/E0205038	SCREENING	        12-09-19	19-09-19
D169CC00001/E0205038	BLINDED TREATMENT	19-09-19	20-02-20
D169CC00001/E0205038	FOLLOW-UP	        20-02-20	 
D169CC00001/E0201025	SCREENING	        26-09-19	03-10-19
D169CC00001/E0201025	BLINDED TREATMENT	03-10-19	08-01-20
D169CC00001/E0201025	FOLLOW-UP	        08-01-20
;
run;

/* From Above two data set are left joined by below code. */
/*before left join created one unique id in CE data */
/*for final output records same as first CE data */

data ce;
  set ce;
  seq_id=_n_;
run;

proc sql;
 create table ce_and_se as
 select a.*,b.epoch,b.sestdtc,b.seendtc
 from ce as a left join se as before on a.usubjid=b.usubjid;
quit;

Output data set as below:
1. Output data set have same observation from first CE data.
2. EPOCH values will be assinged based on date when SESTDTC &amp;lt;= cestdtc &amp;lt; SEENDTC.
3. if cestdtc is missing then epoch will missing values.
4. if  SESTDTC &amp;lt;= cestdtc &amp;lt; SEENDTC this logic not fall then print those values to log (only when cestdtc and SESTDTC and SEENDTC not missing)

/*Final output like below:*/
/*data have */
USUBJID	ceterm	cestdtc	EPOCH
D169CC00001/E0201004	CV DEATH	14-09-21	
D169CC00001/E0201004	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	04-02-20	BLINDED TREATMENT
D169CC00001/E0201004	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	03-09-21	BLINDED TREATMENT
D169CC00001/E0201004	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	04-02-20	BLINDED TREATMENT
D169CC00001/E0201007	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	20-05-21	BLINDED TREATMENT
D169CC00001/E0201025	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	04-06-20	FOLLOW-UP
D169CC00001/E0201025	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	04-06-20	FOLLOW-UP







&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Dec 2021 07:17:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783550#M249862</guid>
      <dc:creator>raja777pharma</dc:creator>
      <dc:date>2021-12-02T07:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative code with easy understading</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783566#M249874</link>
      <description>&lt;P&gt;Please review your codes.&lt;/P&gt;
&lt;P&gt;Make sure that your DATA steps work without ERRORs or invalid data messages in the log.&lt;/P&gt;
&lt;P&gt;Are you sure you want to use a YYMMDD informat and not DDMMYY?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why do you expect those FOLLOW-UP observations to match when their SEENDTC is missing?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, ALWAYS (as in&amp;nbsp;&lt;STRONG&gt;ALWAYS&lt;/STRONG&gt;) use 4-digit years. After the Y2K scare this should be an unquestioned given in computing.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 09:04:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783566#M249874</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-12-02T09:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative code with easy understading</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783575#M249882</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Format of the date variibles would be fine YYMMDD10.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For followup record below condition is met, so assinging the values , if SEENDTC is value then will check the&amp;nbsp;cestdtc &amp;lt; SEENDTC&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;SESTDTC &amp;lt;= cestdtc&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Raja&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 10:20:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783575#M249882</guid>
      <dc:creator>raja777pharma</dc:creator>
      <dc:date>2021-12-02T10:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative code with easy understading</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783577#M249883</link>
      <description>&lt;P&gt;This clarifies exactly NOTHING.&lt;/P&gt;
&lt;P&gt;Please re-post your codes, &lt;U&gt;tested&lt;/U&gt;, with 4-digit years. Make sure to use proper delimiters or the &amp;amp; informat modifier so that the strings with blanks are read correctly. I will not answer further until you do that.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 10:29:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783577#M249883</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-12-02T10:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative code with easy understading</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783594#M249894</link>
      <description>&lt;P&gt;Hello ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have exceuted the below code and data sets were genrated without error.&lt;/P&gt;&lt;P&gt;Also date year is displayed 4 digits in data set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data ce;
input usubjid $1-21 ceterm $22-78 cestdtc yymmdd10.;
format cestdtc yymmdd10.;
datalines;
D169CC00001/E0201004 CV DEATH                                                 14-09-21
D169CC00001/E0201004 HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT 04-02-20
D169CC00001/E0201004 HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT 03-09-21
D169CC00001/E0201004 HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT 04-02-20
D169CC00001/E0201007 HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT 20-05-21
D169CC00001/E0201025 HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT 04-06-20
D169CC00001/E0201025 HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT 04-06-20
;
run;

data se;
input usubjid $1-21 EPOCH $22-39 SESTDTC yyyymmdd10. SEENDTC yyyymmdd10.;
format SESTDTC SEENDTC yyyymmdd10.;
datalines;
D169CC00001/E0201004 SCREENING         07-02-19 12-02-19
D169CC00001/E0201004 BLINDED TREATMENT 12-02-19 15-09-21
D169CC00001/E0201007 SCREENING         01-04-19 08-04-19
D169CC00001/E0201007 BLINDED TREATMENT 08-04-19  
D169CC00001/E0205038 SCREENING         12-09-19 19-09-19
D169CC00001/E0205038 BLINDED TREATMENT 19-09-19 20-02-20
D169CC00001/E0205038 FOLLOW-UP         20-02-20  
D169CC00001/E0201025 SCREENING         26-09-19 03-10-19
D169CC00001/E0201025 BLINDED TREATMENT 03-10-19 08-01-20
D169CC00001/E0201025 FOLLOW-UP         08-01-20
;
run;

data ce;
  set ce;
  seq_id=_n_;
run;

proc sql;
 create table ce_and_se as
 select a.*,b.epoch,b.sestdtc,b.seendtc
 from ce as a left join se as b on a.usubjid=b.usubjid;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;Raja&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 12:18:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783594#M249894</guid>
      <dc:creator>raja777pharma</dc:creator>
      <dc:date>2021-12-02T12:18:51Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative code with easy understading</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783629#M249923</link>
      <description>&lt;P&gt;Where do you see a 4 digit year here:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;14-09-21&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is this 2014-09-21, or 2021-09-14? Since you use the YYMMDD informat, it will be read as the former.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 14:36:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783629#M249923</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-12-02T14:36:26Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative code with easy understading</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783697#M249967</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much helping on to get knowldge more in SAS data step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes , we need to consider ddmmyy10.&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when i used this one&amp;nbsp; for&amp;nbsp;SEENDTC ddmmyy10. getting missing values , i am not sure what is the issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below one is updated one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data ce;
input usubjid $1-21 ceterm $22-78 cestdtc ddmmyy10.;
format cestdtc ddmmyy10.;
datalines;
D169CC00001/E0201004 CV DEATH                                                 14-09-2021
D169CC00001/E0201004 HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT 04-02-2020
D169CC00001/E0201004 HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT 03-09-2021
D169CC00001/E0201004 HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT 04-02-2020
D169CC00001/E0201007 HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT 20-05-2021
D169CC00001/E0201025 HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT 04-06-2020
D169CC00001/E0201025 HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT 04-06-2020
;
run;

data se;
input usubjid $1-21 EPOCH $22-39 SESTDTC ddmmyy10. SEENDTC ddmmyy10.;
format SESTDTC SEENDTC ddmmyy10.;
datalines;
D169CC00001/E0201004 SCREENING         07-02-2019 12-02-2019
D169CC00001/E0201004 BLINDED TREATMENT 12-02-2019 15-09-2019
D169CC00001/E0201007 SCREENING         01-04-2019 08-04-2019
D169CC00001/E0201007 BLINDED TREATMENT 08-04-2019
D169CC00001/E0205038 SCREENING         12-09-2019 19-09-2019
D169CC00001/E0205038 BLINDED TREATMENT 19-09-2019 20-02-2019
D169CC00001/E0205038 FOLLOW-UP         20-02-2019
D169CC00001/E0201025 SCREENING         26-09-2019 03-10-2019
D169CC00001/E0201025 BLINDED TREATMENT 03-10-2019 08-01-2019
D169CC00001/E0201025 FOLLOW-UP         08-01-2019
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Raja&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 17:00:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783697#M249967</guid>
      <dc:creator>raja777pharma</dc:creator>
      <dc:date>2021-12-02T17:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative code with easy understading</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783732#M249991</link>
      <description>&lt;P&gt;Use the colon (:) modifier for the date formats, or INPUT will not honor the delimiter.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 18:48:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783732#M249991</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-12-02T18:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative code with easy understading</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783824#M250025</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you now seendtc have values.&lt;/P&gt;&lt;P&gt;Please find the below code&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data ce;
input usubjid $1-21 ceterm $22-78 cestdtc ddmmyy10.;
format cestdtc ddmmyy10.;
datalines;
D169CC00001/E0201004 CV DEATH                                                 14-09-2021
D169CC00001/E0201004 HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT 04-02-2020
D169CC00001/E0201004 HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT 03-09-2021
D169CC00001/E0201004 HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT 04-02-2020
D169CC00001/E0201007 HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT 20-05-2021
D169CC00001/E0201025 HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT 04-06-2020
D169CC00001/E0201025 HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT 04-06-2020
;
run;

data se;
input usubjid $1-21 EPOCH $22-39 SESTDTC ddmmyy10. SEENDTC :ddmmyy10.;
format SESTDTC SEENDTC ddmmyy10.;
datalines;
D169CC00001/E0201004 SCREENING         07-02-2019 12-02-2019
D169CC00001/E0201004 BLINDED TREATMENT 12-02-2019 15-09-2019
D169CC00001/E0201007 SCREENING         01-04-2019 08-04-2019
D169CC00001/E0201007 BLINDED TREATMENT 08-04-2019
D169CC00001/E0205038 SCREENING         12-09-2019 19-09-2019
D169CC00001/E0205038 BLINDED TREATMENT 19-09-2019 20-02-2019
D169CC00001/E0205038 FOLLOW-UP         20-02-2019
D169CC00001/E0201025 SCREENING         26-09-2019 03-10-2019
D169CC00001/E0201025 BLINDED TREATMENT 03-10-2019 08-01-2019
D169CC00001/E0201025 FOLLOW-UP         08-01-2019
;
run;

data ce;
  set ce;
  seq_id=_n_;
run;

proc sql;
 create table ce_and_se as
 select a.*,b.epoch,b.sestdtc,b.seendtc
 from ce as a left join se as b on a.usubjid=b.usubjid;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Raja.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 03:18:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-code-with-easy-understading/m-p/783824#M250025</guid>
      <dc:creator>raja777pharma</dc:creator>
      <dc:date>2021-12-03T03:18:26Z</dc:date>
    </item>
  </channel>
</rss>

