<?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: Identify Missing Date Records in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identify-Missing-Date-Records/m-p/799778#M314518</link>
    <description>&lt;P&gt;Make sure that the "have" dataset is sorted by name and date, then do a "look-ahead":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
merge
  have
  have (
    firstobs=2
    rename=(
      name=_name
      date=_date
    )
  )
;
output;
if name = _name
then do;
  date = intnx('month',date,1,'e');
  do while (date lt _date);
    output;
    date = intnx('month',date,1,'e');
  end;
end;
drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 03 Mar 2022 08:47:34 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-03-03T08:47:34Z</dc:date>
    <item>
      <title>Identify Missing Date Records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-Missing-Date-Records/m-p/799740#M314487</link>
      <description>Hi all, I'm working on a data that studies people who has come to the library. The data has two fields, Name and Date.&lt;BR /&gt;&lt;BR /&gt;Example of the data:&lt;BR /&gt;Name Date&lt;BR /&gt;Ben 31Dec2013&lt;BR /&gt;Ben 31Jan2014&lt;BR /&gt;Ben 31Mar2014&lt;BR /&gt;Ben 30Apr2014&lt;BR /&gt;Ben 30Jun2014&lt;BR /&gt;Ken 31Mar2014&lt;BR /&gt;Ken 31May2014&lt;BR /&gt;&lt;BR /&gt;I would like SAS to tell me which date that a visitor had not visited from their continuous trip since their first record until their last record, hence using above as an example, I will need SAS to tell me Ben did not visit on Feb2014 and May2014 and Ken did not visit on Apr2014.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.</description>
      <pubDate>Thu, 03 Mar 2022 05:56:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-Missing-Date-Records/m-p/799740#M314487</guid>
      <dc:creator>sas51</dc:creator>
      <dc:date>2022-03-03T05:56:17Z</dc:date>
    </item>
    <item>
      <title>Re: Identify Missing Date Records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-Missing-Date-Records/m-p/799773#M314514</link>
      <description>&lt;P&gt;I'm merging them once I've made the list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Name $ Date:date9.;
format date date9.;
datalines;
Ben 31Dec2013
Ben 31Jan2014
Ben 31Mar2014
Ben 30Apr2014
Ben 30Jun2014
Ken 31Mar2014
Ken 31May2014
;
run;

proc sort data=have out=sorted;
  by Name Date;
run;

data datelist_main;
  set sorted;
  by Name Date;
  if first.name or last.name;
run;
data datelist(rename=(dt=DATE));
  set datelist_main;
  by Name Date;
  retain dt;
  if first.name then do;
    dt=date;
    output;
  end;
  if last.name then do;
    do while(dt&amp;lt;Date);
      dt=intnx('month',dt,1,'end');
      output;
    end;
  end;
  drop date;
run;


data want;
  merge datelist(in=inA) have(in=inB);
  by name date;
  if inA and not(inB);
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Mar 2022 08:10:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-Missing-Date-Records/m-p/799773#M314514</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2022-03-03T08:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: Identify Missing Date Records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-Missing-Date-Records/m-p/799778#M314518</link>
      <description>&lt;P&gt;Make sure that the "have" dataset is sorted by name and date, then do a "look-ahead":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
merge
  have
  have (
    firstobs=2
    rename=(
      name=_name
      date=_date
    )
  )
;
output;
if name = _name
then do;
  date = intnx('month',date,1,'e');
  do while (date lt _date);
    output;
    date = intnx('month',date,1,'e');
  end;
end;
drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Mar 2022 08:47:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-Missing-Date-Records/m-p/799778#M314518</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-03T08:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: Identify Missing Date Records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-Missing-Date-Records/m-p/799813#M314539</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Name $ Date:date9.;
format date date9.;
datalines;
Ben 31Dec2013
Ben 31Jan2014
Ben 31Mar2014
Ben 30Apr2014
Ben 30Jun2014
Ken 31Mar2014
Ken 31May2014
;
run;

data want;
merge have have(rename=(name=_name date=_date) firstobs=2);
if name=_name then do;
 do i=1 to intck('month',intnx('month',date,0),intnx('month',_date,0)-1);
   want_date=intnx('month',date,i);output;
 end;
end;
format want_date date9.;
keep name want_date;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Mar 2022 12:17:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-Missing-Date-Records/m-p/799813#M314539</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-03-03T12:17:44Z</dc:date>
    </item>
  </channel>
</rss>

