<?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 Capturing Visit Dates for Anchor Visits in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Capturing-Visit-Dates-for-Anchor-Visits/m-p/597458#M172149</link>
    <description>&lt;P&gt;I have done this several times, but I cannot find past code or remember what I did even though I know this is a pretty simple task.&amp;nbsp; I think I'm just going brain dead and can't think anymore.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a table of patient visits and dates (DOV) and another table of visits and anchor visits (WINDOWS) so I can try to find out if a visit is outside of the protocol-specified window.&amp;nbsp; I cannot think how to identify the anchor date (the EVENTDT that corresponds with the ANCHOR visit).&amp;nbsp; In the end, I want to see the DOV table with a new variable called ANCHORDT that should have values of 2019-09-05 for Subject 001-001-001 and 2019-09-06 for Subject 001-001-004 (but the Termination visits should not have an anchor date since that is not found in the WINDOWS table).&amp;nbsp; This is a very simple example, but in real life there could be multiple anchor dates per subject (just depending on what visit is assigned to be the anchor for each following visit).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my sample data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table dov (SUBJID char(11), EVENT char(50), EVENTDT char(10));
	insert into dov (subjid, event, eventdt)
		values ('001-001-001', 'Screening', '2019-08-20')
		values ('001-001-001', 'Day -1', '2019-09-04')
		values ('001-001-001', 'Randomization', '2019-09-04')
		values ('001-001-001', 'Part A Treatment Period Day 1', '2019-09-05')
		values ('001-001-001', 'Part A Treatment Period Day 2', '2019-09-06')
		values ('001-001-001', 'Part A Treatment Period Day 3', '2019-09-07')
		values ('001-001-001', 'Part A Treatment Period Day 4', '2019-09-08')
		values ('001-001-001', 'Part A Treatment Period Day 5', '2019-09-09')
		values ('001-001-001', 'Termination', '2019-09-12')
		values ('001-001-004', 'Screening', '2019-08-22')
		values ('001-001-004', 'Day -1', '2019-09-05')
		values ('001-001-004', 'Randomization', '2019-09-06')
		values ('001-001-004', 'Part A Treatment Period Day 1', '2019-09-06')
		values ('001-001-004', 'Part A Treatment Period Day 2', '2019-09-07')
		values ('001-001-004', 'Part A Treatment Period Day 3', '2019-09-08')
		values ('001-001-004', 'Part A Treatment Period Day 4', '2019-09-09')
		values ('001-001-004', 'Part A Treatment Period Day 5', '2019-09-10')
		values ('001-001-004', 'Termination', '2019-09-13');
	create table windows (EVENT char(50), MIN_WINDOW num, MAX_WINDOW num, ANCHOR char(50));
	insert into windows (event, min_window, max_window, anchor)
		values('Screening', -28, -2, 'Part A Treatment Period Day 1')
		values('Day -1', -1, -1, 'Part A Treatment Period Day 1')
		values('Randomization', 1, 1, 'Part A Treatment Period Day 1')
		values('Part A Treatment Period Day 1', 1, 1, 'Part A Treatment Period Day 1')
		values('Part A Treatment Period Day 2', 2, 2, 'Part A Treatment Period Day 1')
		values('Part A Treatment Period Day 3', 3, 3, 'Part A Treatment Period Day 1')
		values('Part A Treatment Period Day 4', 4, 4, 'Part A Treatment Period Day 1')
		values('Part A Treatment Period Day 5', 5, 5, 'Part A Treatment Period Day 1')
		values('Part A Safety Follow-up', 7, 10, 'Part A Treatment Period Day 1');
quit;
&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Oct 2019 18:03:40 GMT</pubDate>
    <dc:creator>djbateman</dc:creator>
    <dc:date>2019-10-17T18:03:40Z</dc:date>
    <item>
      <title>Capturing Visit Dates for Anchor Visits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-Visit-Dates-for-Anchor-Visits/m-p/597458#M172149</link>
      <description>&lt;P&gt;I have done this several times, but I cannot find past code or remember what I did even though I know this is a pretty simple task.&amp;nbsp; I think I'm just going brain dead and can't think anymore.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a table of patient visits and dates (DOV) and another table of visits and anchor visits (WINDOWS) so I can try to find out if a visit is outside of the protocol-specified window.&amp;nbsp; I cannot think how to identify the anchor date (the EVENTDT that corresponds with the ANCHOR visit).&amp;nbsp; In the end, I want to see the DOV table with a new variable called ANCHORDT that should have values of 2019-09-05 for Subject 001-001-001 and 2019-09-06 for Subject 001-001-004 (but the Termination visits should not have an anchor date since that is not found in the WINDOWS table).&amp;nbsp; This is a very simple example, but in real life there could be multiple anchor dates per subject (just depending on what visit is assigned to be the anchor for each following visit).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my sample data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table dov (SUBJID char(11), EVENT char(50), EVENTDT char(10));
	insert into dov (subjid, event, eventdt)
		values ('001-001-001', 'Screening', '2019-08-20')
		values ('001-001-001', 'Day -1', '2019-09-04')
		values ('001-001-001', 'Randomization', '2019-09-04')
		values ('001-001-001', 'Part A Treatment Period Day 1', '2019-09-05')
		values ('001-001-001', 'Part A Treatment Period Day 2', '2019-09-06')
		values ('001-001-001', 'Part A Treatment Period Day 3', '2019-09-07')
		values ('001-001-001', 'Part A Treatment Period Day 4', '2019-09-08')
		values ('001-001-001', 'Part A Treatment Period Day 5', '2019-09-09')
		values ('001-001-001', 'Termination', '2019-09-12')
		values ('001-001-004', 'Screening', '2019-08-22')
		values ('001-001-004', 'Day -1', '2019-09-05')
		values ('001-001-004', 'Randomization', '2019-09-06')
		values ('001-001-004', 'Part A Treatment Period Day 1', '2019-09-06')
		values ('001-001-004', 'Part A Treatment Period Day 2', '2019-09-07')
		values ('001-001-004', 'Part A Treatment Period Day 3', '2019-09-08')
		values ('001-001-004', 'Part A Treatment Period Day 4', '2019-09-09')
		values ('001-001-004', 'Part A Treatment Period Day 5', '2019-09-10')
		values ('001-001-004', 'Termination', '2019-09-13');
	create table windows (EVENT char(50), MIN_WINDOW num, MAX_WINDOW num, ANCHOR char(50));
	insert into windows (event, min_window, max_window, anchor)
		values('Screening', -28, -2, 'Part A Treatment Period Day 1')
		values('Day -1', -1, -1, 'Part A Treatment Period Day 1')
		values('Randomization', 1, 1, 'Part A Treatment Period Day 1')
		values('Part A Treatment Period Day 1', 1, 1, 'Part A Treatment Period Day 1')
		values('Part A Treatment Period Day 2', 2, 2, 'Part A Treatment Period Day 1')
		values('Part A Treatment Period Day 3', 3, 3, 'Part A Treatment Period Day 1')
		values('Part A Treatment Period Day 4', 4, 4, 'Part A Treatment Period Day 1')
		values('Part A Treatment Period Day 5', 5, 5, 'Part A Treatment Period Day 1')
		values('Part A Safety Follow-up', 7, 10, 'Part A Treatment Period Day 1');
quit;
&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 18:03:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-Visit-Dates-for-Anchor-Visits/m-p/597458#M172149</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2019-10-17T18:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing Visit Dates for Anchor Visits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-Visit-Dates-for-Anchor-Visits/m-p/597477#M172153</link>
      <description>&lt;P&gt;curious? Is your Anchor Day always going to be the first treatment day? i.e. "&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #800000; font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 16.8px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px white; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;Part A Treatment Period Day 1&lt;/SPAN&gt;"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A Strange numbering system for "days".&amp;nbsp; Am I understanding that there is not a "zero" day?&amp;nbsp; That makes the math funny, does it not?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 19:30:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-Visit-Dates-for-Anchor-Visits/m-p/597477#M172153</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2019-10-17T19:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing Visit Dates for Anchor Visits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-Visit-Dates-for-Anchor-Visits/m-p/597481#M172156</link>
      <description>It's not always "Part A Treatment Period Day 1" in real life, but my simplified example does happen to be.&lt;BR /&gt;&lt;BR /&gt;No, there is no Day 0, so I do need to adjust the windows for that visit.</description>
      <pubDate>Thu, 17 Oct 2019 19:36:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-Visit-Dates-for-Anchor-Visits/m-p/597481#M172156</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2019-10-17T19:36:15Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing Visit Dates for Anchor Visits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-Visit-Dates-for-Anchor-Visits/m-p/597719#M172242</link>
      <description>&lt;P&gt;I figured it out.&amp;nbsp; I thought it would be a simple single SQL query, but it was a little more work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=dov;
	by event;
proc sort data=windows;
	by event;
run;

data dov_ref;
	merge dov (in=a) windows (in=b);
	by event;
	if a&amp;amp;b;
run;
proc sort data=dov_ref;
	by subjid eventdt;
run;

proc sql;
	create table anchordt as
	select subjid, anchor, eventdt as ANCHORDT
	from dov_ref
	having event=anchor
	order by subjid;
quit;


data dov_window;
	merge dov_ref anchordt;
	by subjid;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Oct 2019 13:54:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-Visit-Dates-for-Anchor-Visits/m-p/597719#M172242</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2019-10-18T13:54:07Z</dc:date>
    </item>
  </channel>
</rss>

