<?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: PROC SQL: Inputting dates into time periods and creating missing values when needed in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/PROC-SQL-Inputting-dates-into-time-periods-and-creating-missing/m-p/315406#M9024</link>
    <description>&lt;P&gt;It is not clear why you use a full outer join. I would do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table allvisits as
select 
	i.*, 
	v.subjectId as visitSubjectId,
	v.visitdate /* More visits fields */
from 
	kelsey.periods as i left join
	kelsey.clinicvisits as v on 
		i.subjectid = v.subjectid and 
		v.visitdate between i.startdate and i.enddate;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 30 Nov 2016 04:02:43 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-11-30T04:02:43Z</dc:date>
    <item>
      <title>PROC SQL: Inputting dates into time periods and creating missing values when needed</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/PROC-SQL-Inputting-dates-into-time-periods-and-creating-missing/m-p/315373#M9022</link>
      <description>&lt;P class="p1"&gt;I have a database of time periods that represent different environments (the same study subject can have multiple time periods depending on how many environments they were in). I have a second dataset containing clinic visits and the corresponding dates of those visits. I would like to input these clinic visits (and dates) into the appropriate time periods (delineated by startdate and enddate). To do this, I have a code like this, which sort of works:&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;/*combine time periods and visit datasets together, keep records where visit date between start and end dates for each period*/&lt;/P&gt;&lt;P class="p1"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt;;&lt;/P&gt;&lt;P class="p1"&gt;create table allvisits as&lt;/P&gt;&lt;P class="p1"&gt;select i.*, v.*&lt;/P&gt;&lt;P class="p1"&gt;from kelsey.periods i full outer join kelsey.clinicvisits v&lt;/P&gt;&lt;P class="p1"&gt;on i.subjectid=v.subjectid&lt;/P&gt;&lt;P class="p1"&gt;where i.startdate&amp;lt;=v.visitdate&amp;lt;=i.enddate ;&lt;/P&gt;&lt;P class="p1"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;The problem is that there are sometimes time periods where no clinic visits took place during those time periods; the code below results in those time periods getting dropped and I don't want to do that because I am also interested in situations were no clinic visit was done. Is there a way to modify this code so that for records where there is no visit date that corresponds to a time period's start and end dates, I can&amp;nbsp;still retain that time period and make the visitdate=missing? Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2016 23:51:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/PROC-SQL-Inputting-dates-into-time-periods-and-creating-missing/m-p/315373#M9022</guid>
      <dc:creator>Kels123</dc:creator>
      <dc:date>2016-11-29T23:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL: Inputting dates into time periods and creating missing values when needed</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/PROC-SQL-Inputting-dates-into-time-periods-and-creating-missing/m-p/315376#M9023</link>
      <description>&lt;P&gt;You could but your probably better off handling that in your end reporting. Depending on the proc used to summarize results you may be able to add the time period in at that point more easily.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 00:06:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/PROC-SQL-Inputting-dates-into-time-periods-and-creating-missing/m-p/315376#M9023</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-11-30T00:06:03Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL: Inputting dates into time periods and creating missing values when needed</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/PROC-SQL-Inputting-dates-into-time-periods-and-creating-missing/m-p/315406#M9024</link>
      <description>&lt;P&gt;It is not clear why you use a full outer join. I would do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table allvisits as
select 
	i.*, 
	v.subjectId as visitSubjectId,
	v.visitdate /* More visits fields */
from 
	kelsey.periods as i left join
	kelsey.clinicvisits as v on 
		i.subjectid = v.subjectid and 
		v.visitdate between i.startdate and i.enddate;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Nov 2016 04:02:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/PROC-SQL-Inputting-dates-into-time-periods-and-creating-missing/m-p/315406#M9024</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-11-30T04:02:43Z</dc:date>
    </item>
  </channel>
</rss>

