<?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: Input row at each instance of change OR at 12 months in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Input-row-at-each-instance-of-change-OR-at-12-months/m-p/355183#M83194</link>
    <description>&lt;P&gt;Ah, ok I had it only for over 1 year, not the same as:&lt;/P&gt;
&lt;PRE&gt;data have;
  informat id 1. date_record mmddyy10. metric 1. metric_change $1.;
  input id date_record metric metric_change;
  format date_record date9.;
datalines;
1 01/01/2010 5 n
1 01/01/2011 5 n
1 01/01/2014 6 y
1 06/01/2014 6 n
1 11/30/2014 6 n
1 05/01/2015 8 y
1 12/01/2015 3 y
2 03/01/2015 3 n
2 03/05/2015 4 y
2 02/28/2016 5 y
;
run;

data want (drop=dt);
  set have;
  by id;
  retain dt;
  if first.id then do;
    date_wanted=date_record;
    dt=date_record;
  end;
  if metric_change="y" then date_wanted=date_record;
  if date_record &amp;gt;= intnx('month',dt,12) then do;
    date_wanted=date_record;
    dt=date_record;
  end;
  format date_wanted date9.;
run;&lt;/PRE&gt;</description>
    <pubDate>Tue, 02 May 2017 10:06:16 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-05-02T10:06:16Z</dc:date>
    <item>
      <title>Input row at each instance of change OR at 12 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-row-at-each-instance-of-change-OR-at-12-months/m-p/355171#M83190</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to add a dummy date variable:&lt;/P&gt;
&lt;P&gt;- if the metric column value changes&lt;/P&gt;
&lt;P&gt;- every 12 months after the first recorded date for the by group (id) even if the metric column value doesn't change&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can someone help produce the WANT dataset? Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P.S.: Even if metric doesn't change I need a date populated every 12 months after the first known date of each id.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; have;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;informat&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; id &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; date_record &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;mmddyy10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; metric &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; metric_change &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;$1.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; id date_record metric metric_change;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; date_record &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;date9.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;1 01/01/2010 5 n&lt;/P&gt;
&lt;P&gt;1 01/01/2011 5 n&lt;/P&gt;
&lt;P&gt;1 01/01/2014 6 y&lt;/P&gt;
&lt;P&gt;1 06/01/2014 6 n&lt;/P&gt;
&lt;P&gt;1 11/30/2014 6 n&lt;/P&gt;
&lt;P&gt;1 05/01/2015 8 y&lt;/P&gt;
&lt;P&gt;1 12/01/2015 3 y&lt;/P&gt;
&lt;P&gt;2 03/01/2015 3 n&lt;/P&gt;
&lt;P&gt;2 03/05/2015 4 y&lt;/P&gt;
&lt;P&gt;2 02/28/2016 5 y&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; want;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;informat&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; id &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; date_record &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;mmddyy10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; metric &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; date_wanted &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;mmddyy10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; id date_record metric date_wanted;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; date_record &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;date9.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; date_wanted &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;date9.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;1 01/01/2010 5 01/01/2010&lt;/P&gt;
&lt;P&gt;1 01/01/2011 5 01/01/2011&lt;/P&gt;
&lt;P&gt;1 5 01/01/2012&lt;/P&gt;
&lt;P&gt;1 5 01/01/2013&lt;/P&gt;
&lt;P&gt;1 01/01/2014 6 01/01/2014&lt;/P&gt;
&lt;P&gt;1 6 01/01/2015&lt;/P&gt;
&lt;P&gt;1 05/01/2015 8 05/01/2015&lt;/P&gt;
&lt;P&gt;1 12/01/2015 3 12/01/2015&lt;/P&gt;
&lt;P&gt;2 03/01/2015 3 03/01/2015&lt;/P&gt;
&lt;P&gt;2 03/05/2015 4 03/05/2015&lt;/P&gt;
&lt;P&gt;2 4 03/05/2016&lt;/P&gt;
&lt;P&gt;2 02/28/2016 5 02/28/2016&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2017 09:41:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-row-at-each-instance-of-change-OR-at-12-months/m-p/355171#M83190</guid>
      <dc:creator>Jane7476</dc:creator>
      <dc:date>2017-05-02T09:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: Input row at each instance of change OR at 12 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-row-at-each-instance-of-change-OR-at-12-months/m-p/355173#M83191</link>
      <description>&lt;P&gt;Firstly, you already have your dummy variable coded as y/n on whether the metric values change from one row to the next?&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2017 09:44:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-row-at-each-instance-of-change-OR-at-12-months/m-p/355173#M83191</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-05-02T09:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: Input row at each instance of change OR at 12 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-row-at-each-instance-of-change-OR-at-12-months/m-p/355176#M83192</link>
      <description>&lt;P&gt;I couldn't follow your logic versus required output very well, why does row two have a date as that isn't a change, nor is it a year after, then next row however is:&lt;/P&gt;
&lt;PRE&gt;data have;
  informat id 1. date_record mmddyy10. metric 1. metric_change $1.;
  input id date_record metric metric_change;
  format date_record date9.;
datalines;
1 01/01/2010 5 n
1 01/01/2011 5 n
1 01/01/2014 6 y
1 06/01/2014 6 n
1 11/30/2014 6 n
1 05/01/2015 8 y
1 12/01/2015 3 y
2 03/01/2015 3 n
2 03/05/2015 4 y
2 02/28/2016 5 y
;
run;

data want (drop=dt);
  set have;
  by id;
  retain dt;
  if first.id then do;
    date_wanted=date_record;
    dt=date_record;
  end;
  if metric_change="y" then date_wanted=date_record;
  if date_record &amp;gt; intnx('month',dt,12) then do;
    date_wanted=date_record;
    dt=date_record;
  end;
  format date_wanted date9.;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 May 2017 09:50:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-row-at-each-instance-of-change-OR-at-12-months/m-p/355176#M83192</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-02T09:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: Input row at each instance of change OR at 12 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-row-at-each-instance-of-change-OR-at-12-months/m-p/355181#M83193</link>
      <description>&lt;P&gt;Thanks RW9.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first instance of change in METRIC (from 5 to 6) for id 1 is on 01/01/2014. Before this it has two dates - 01/01/2010 and 01/01/2011.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case the the records i need for id 1 are:&lt;/P&gt;
&lt;P&gt;01/01/2010&amp;nbsp; ----this is the first instance so needed&lt;/P&gt;
&lt;P&gt;01/01/2011 -----this is the instance after a year where data is available but no change in metric observed&lt;/P&gt;
&lt;P&gt;01/01/2012 -----new row of data need as date is&amp;nbsp;one year after previous row (even if no change in metric)&lt;/P&gt;
&lt;P&gt;01/01/2013&amp;nbsp;-----new row of data need as date is&amp;nbsp;one year after previous row (even if no change in metric)&lt;/P&gt;
&lt;P&gt;01/01/2014------this is a change in metric record so need it&lt;/P&gt;
&lt;P&gt;01/01/2015------new row of data need as date is&amp;nbsp;one year after previous row (even if no change in metric)&lt;/P&gt;
&lt;P&gt;05/01/2015------this is a change in metric record so need it&amp;nbsp;&lt;/P&gt;
&lt;P&gt;12/01/2015------this is a change in metric record so need it&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this clarifies things. I need date at every 12 months irrespective of change in metric.&amp;nbsp;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2017 10:02:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-row-at-each-instance-of-change-OR-at-12-months/m-p/355181#M83193</guid>
      <dc:creator>Jane7476</dc:creator>
      <dc:date>2017-05-02T10:02:21Z</dc:date>
    </item>
    <item>
      <title>Re: Input row at each instance of change OR at 12 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-row-at-each-instance-of-change-OR-at-12-months/m-p/355183#M83194</link>
      <description>&lt;P&gt;Ah, ok I had it only for over 1 year, not the same as:&lt;/P&gt;
&lt;PRE&gt;data have;
  informat id 1. date_record mmddyy10. metric 1. metric_change $1.;
  input id date_record metric metric_change;
  format date_record date9.;
datalines;
1 01/01/2010 5 n
1 01/01/2011 5 n
1 01/01/2014 6 y
1 06/01/2014 6 n
1 11/30/2014 6 n
1 05/01/2015 8 y
1 12/01/2015 3 y
2 03/01/2015 3 n
2 03/05/2015 4 y
2 02/28/2016 5 y
;
run;

data want (drop=dt);
  set have;
  by id;
  retain dt;
  if first.id then do;
    date_wanted=date_record;
    dt=date_record;
  end;
  if metric_change="y" then date_wanted=date_record;
  if date_record &amp;gt;= intnx('month',dt,12) then do;
    date_wanted=date_record;
    dt=date_record;
  end;
  format date_wanted date9.;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 May 2017 10:06:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-row-at-each-instance-of-change-OR-at-12-months/m-p/355183#M83194</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-02T10:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: Input row at each instance of change OR at 12 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-row-at-each-instance-of-change-OR-at-12-months/m-p/355197#M83198</link>
      <description>&lt;P&gt;What changes will I have to make to&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; date_record &amp;gt;= intnx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'month'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,dt,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;12&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;date_wanted=date_record;&lt;/P&gt;
&lt;P&gt;dt=date_record;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to ensure that I am putting in dummy rows with dates at yearly intervals even if there is no change in metric?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2017 11:09:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-row-at-each-instance-of-change-OR-at-12-months/m-p/355197#M83198</guid>
      <dc:creator>Jane7476</dc:creator>
      <dc:date>2017-05-02T11:09:33Z</dc:date>
    </item>
  </channel>
</rss>

