<?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: Calculating calving intervals with dates in columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculating-calving-intervals-with-dates-in-columns/m-p/396556#M278131</link>
    <description>Hello, sorry for bothering you again, i just got one more question:&lt;BR /&gt;&lt;BR /&gt;If i would like to know the interval of days between each different date for cows with multiple dates (More that 2 dates) what can i do?&lt;BR /&gt;&lt;BR /&gt;Ex.&lt;BR /&gt;Cow Calving date&lt;BR /&gt;4 02/08/2008&lt;BR /&gt;4 13/10/2009&lt;BR /&gt;4 21/06/2011&lt;BR /&gt;4 17/09/2012&lt;BR /&gt;&lt;BR /&gt;What are the interval or range of days between 02/08/2008 and 13/10/2009, and 13/10/2009 to 21/06/2011 and so and so.&lt;BR /&gt;&lt;BR /&gt;What can i do or modify to achieve this?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance btw</description>
    <pubDate>Sat, 16 Sep 2017 09:44:40 GMT</pubDate>
    <dc:creator>magician</dc:creator>
    <dc:date>2017-09-16T09:44:40Z</dc:date>
    <item>
      <title>Calculating calving intervals with dates in columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-calving-intervals-with-dates-in-columns/m-p/396259#M278123</link>
      <description>&lt;P&gt;I have the following data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA A;&lt;BR /&gt;INPUT cow $ calvingdate :ddmmyy10.;&lt;BR /&gt;DATALINES;&lt;BR /&gt;1 15/08/2008&lt;BR /&gt;4 02/08/2008&lt;BR /&gt;4 13/10/2009&lt;BR /&gt;4 13/10/2009&lt;BR /&gt;4 21/06/2011&lt;BR /&gt;4 17/09/2012&lt;BR /&gt;14 30/12/2009&lt;BR /&gt;14 16/03/2012&lt;BR /&gt;18 01/02/2009&lt;BR /&gt;18 19/01/2011&lt;BR /&gt;27 18/10/2008&lt;BR /&gt;34 02/07/2009&lt;BR /&gt;34 29/12/2010&lt;BR /&gt;34 31/07/2012&lt;BR /&gt;37 11/09/2008&lt;BR /&gt;37 29/07/2009&lt;BR /&gt;37 24/06/2011&lt;BR /&gt;39 10/01/2008&lt;BR /&gt;39 02/02/2009&lt;BR /&gt;39 10/02/2011&lt;BR /&gt;40 11/01/2008&lt;BR /&gt;41 15/10/2008&lt;BR /&gt;41 21/06/2011&lt;BR /&gt;44 04/03/2008&lt;BR /&gt;44 22/11/2010&lt;BR /&gt;44 27/10/2012&lt;BR /&gt;45 02/04/2008&lt;BR /&gt;45 30/07/2009&lt;BR /&gt;47 29/10/2008&lt;BR /&gt;49 30/03/2008&lt;BR /&gt;49 03/01/2011&lt;BR /&gt;51 17/04/2008&lt;BR /&gt;53 11/03/2008&lt;BR /&gt;53 11/11/2009&lt;BR /&gt;53 10/12/2010&lt;BR /&gt;53 26/10/2012&lt;BR /&gt;54 07/07/2008&lt;BR /&gt;54 03/03/2010&lt;BR /&gt;54 06/02/2011&lt;BR /&gt;54 17/12/2012&lt;BR /&gt;54 26/01/2014&lt;BR /&gt;54 26/01/2014&lt;BR /&gt;55 06/05/2008&lt;BR /&gt;55 15/09/2009&lt;BR /&gt;55 01/08/2011&lt;BR /&gt;55 01/08/2011&lt;BR /&gt;56 27/12/2008&lt;BR /&gt;56 12/08/2010&lt;BR /&gt;56 03/10/2011&lt;BR /&gt;56 08/09/2012&lt;BR /&gt;56 26/10/2013&lt;BR /&gt;58 15/10/2008&lt;BR /&gt;59 29/10/2008&lt;BR /&gt;59 16/09/2009&lt;BR /&gt;61 23/10/2008&lt;BR /&gt;61 10/08/2010&lt;BR /&gt;62 06/08/2008&lt;BR /&gt;62 13/07/2009&lt;BR /&gt;64 16/10/2008&lt;BR /&gt;64 07/08/2010&lt;BR /&gt;64 16/09/2011&lt;BR /&gt;64 21/10/2012&lt;BR /&gt;66 09/04/2009&lt;BR /&gt;66 30/07/2010&lt;BR /&gt;66 31/07/2012&lt;BR /&gt;66 06/01/2014&lt;BR /&gt;66 05/10/2015&lt;BR /&gt;68 15/09/2008&lt;BR /&gt;68 21/06/2011&lt;BR /&gt;68 06/01/2014&lt;BR /&gt;69 10/09/2008&lt;BR /&gt;69 28/07/2012&lt;BR /&gt;69 25/09/2013&lt;BR /&gt;69 01/09/2014&lt;BR /&gt;76 25/08/2009&lt;BR /&gt;76 31/07/2011&lt;BR /&gt;76 14/03/2013&lt;BR /&gt;77 25/05/2009&lt;BR /&gt;77 17/02/2011&lt;BR /&gt;79 11/07/2009&lt;BR /&gt;79 13/08/2010&lt;BR /&gt;79 02/03/2012&lt;BR /&gt;79 20/10/2013&lt;BR /&gt;80 30/07/2009&lt;BR /&gt;81 04/07/2009&lt;BR /&gt;82 20/06/2009&lt;BR /&gt;82 09/02/2011&lt;BR /&gt;82 25/10/2012&lt;BR /&gt;83 07/11/2009&lt;BR /&gt;83 13/12/2010&lt;BR /&gt;83 07/12/2011&lt;BR /&gt;83 07/12/2011&lt;BR /&gt;86 31/08/2009&lt;BR /&gt;86 31/12/2010&lt;BR /&gt;86 10/02/2013&lt;BR /&gt;87 09/06/2009&lt;BR /&gt;87 24/02/2012&lt;BR /&gt;90 22/07/2009&lt;BR /&gt;90 29/10/2011&lt;BR /&gt;90 16/02/2013&lt;BR /&gt;90 24/03/2014&lt;BR /&gt;91 15/11/2009&lt;BR /&gt;91 01/09/2011&lt;BR /&gt;92 18/07/2010&lt;BR /&gt;92 16/07/2011&lt;BR /&gt;92 12/03/2013&lt;BR /&gt;92 09/10/2014&lt;BR /&gt;92 19/11/2016&lt;BR /&gt;93 27/08/2010&lt;BR /&gt;93 05/10/2011&lt;BR /&gt;93 22/12/2012&lt;BR /&gt;93 07/10/2014&lt;BR /&gt;95 15/01/2012&lt;BR /&gt;95 15/01/2012&lt;BR /&gt;95 29/09/2014&lt;BR /&gt;95 16/01/2016&lt;BR /&gt;98 08/03/2011&lt;BR /&gt;98 20/03/2012&lt;BR /&gt;98 14/08/2013&lt;BR /&gt;98 15/11/2014&lt;BR /&gt;98 17/11/2015&lt;BR /&gt;98 18/11/2016&lt;BR /&gt;99 30/08/2010&lt;BR /&gt;99 14/02/2012&lt;BR /&gt;99 11/08/2013&lt;BR /&gt;102 25/07/2010&lt;BR /&gt;102 25/09/2011&lt;BR /&gt;102 04/03/2013&lt;BR /&gt;102 22/01/2014&lt;BR /&gt;102 25/07/2015&lt;BR /&gt;104 03/08/2010&lt;BR /&gt;104 13/07/2011&lt;BR /&gt;104 27/09/2012&lt;BR /&gt;104 13/02/2014&lt;BR /&gt;104 29/01/2015&lt;BR /&gt;104 14/11/2016&lt;BR /&gt;105 19/08/2010&lt;BR /&gt;105 14/07/2011&lt;BR /&gt;105 09/10/2012&lt;BR /&gt;105 04/09/2013&lt;BR /&gt;106 21/11/2010&lt;BR /&gt;106 06/12/2011&lt;BR /&gt;106 06/12/2011&lt;BR /&gt;106 03/08/2013&lt;BR /&gt;106 20/08/2014&lt;BR /&gt;107 07/08/2010&lt;BR /&gt;107 11/10/2011&lt;BR /&gt;107 06/12/2012&lt;BR /&gt;107 20/02/2015&lt;BR /&gt;108 23/08/2010&lt;BR /&gt;108 29/07/2011&lt;BR /&gt;108 29/07/2011&lt;BR /&gt;108 08/09/2013&lt;BR /&gt;108 29/08/2014&lt;BR /&gt;108 25/08/2015&lt;BR /&gt;111 16/07/2011&lt;BR /&gt;111 29/12/2012&lt;BR /&gt;112 04/10/2010&lt;BR /&gt;112 14/09/2011&lt;BR /&gt;112 10/08/2012&lt;BR /&gt;112 10/08/2012&lt;BR /&gt;112 27/02/2014&lt;BR /&gt;112 27/02/2014&lt;BR /&gt;112 16/03/2016&lt;BR /&gt;113 07/03/2011&lt;BR /&gt;113 31/07/2012&lt;BR /&gt;113 29/08/2013&lt;BR /&gt;113 29/08/2013&lt;BR /&gt;113 29/10/2014&lt;BR /&gt;113 03/03/2016&lt;BR /&gt;114 09/03/2011&lt;BR /&gt;114 25/02/2012&lt;BR /&gt;114 31/10/2013&lt;BR /&gt;114 06/04/2015&lt;BR /&gt;115 08/07/2011&lt;BR /&gt;115 08/07/2011&lt;BR /&gt;116 13/07/2011&lt;BR /&gt;118 01/08/2011&lt;BR /&gt;119 19/10/2011&lt;BR /&gt;119 19/10/2013&lt;BR /&gt;120 13/07/2011&lt;BR /&gt;120 17/10/2012&lt;BR /&gt;120 24/09/2013&lt;BR /&gt;120 24/09/2013&lt;BR /&gt;120 13/10/2014&lt;BR /&gt;120 25/08/2015&lt;BR /&gt;120 06/01/2017&lt;BR /&gt;123 27/07/2011&lt;BR /&gt;123 23/03/2014&lt;BR /&gt;126 14/07/2011&lt;BR /&gt;126 17/12/2012&lt;BR /&gt;126 01/02/2014&lt;BR /&gt;126 26/09/2015&lt;BR /&gt;126 04/01/2017&lt;BR /&gt;129 02/11/2011&lt;BR /&gt;129 05/09/2013&lt;BR /&gt;129 03/08/2015&lt;BR /&gt;129 03/08/2015&lt;BR /&gt;130 07/11/2011&lt;BR /&gt;130 12/02/2013&lt;BR /&gt;130 03/02/2014&lt;BR /&gt;131 19/01/2012&lt;BR /&gt;131 26/12/2013&lt;BR /&gt;132 19/07/2012&lt;BR /&gt;133 30/11/2011&lt;BR /&gt;133 08/12/2012&lt;BR /&gt;133 08/12/2012&lt;BR /&gt;133 23/12/2013&lt;BR /&gt;133 18/08/2015&lt;BR /&gt;133 28/10/2016&lt;BR /&gt;133 28/10/2016&lt;BR /&gt;134 23/09/2012&lt;BR /&gt;134 16/12/2013&lt;BR /&gt;134 17/02/2016&lt;BR /&gt;134 11/03/2017&lt;BR /&gt;137 24/09/2012&lt;BR /&gt;137 04/09/2013&lt;BR /&gt;137 11/10/2014&lt;BR /&gt;137 02/10/2015&lt;BR /&gt;137 30/01/2017&lt;BR /&gt;138 22/12/2012&lt;BR /&gt;138 05/03/2014&lt;BR /&gt;138 31/08/2015&lt;BR /&gt;138 14/01/2017&lt;BR /&gt;139 23/09/2012&lt;BR /&gt;139 05/09/2013&lt;BR /&gt;140 07/09/2012&lt;BR /&gt;140 28/08/2014&lt;BR /&gt;140 08/09/2015&lt;BR /&gt;140 22/12/2016&lt;BR /&gt;142 24/09/2012&lt;BR /&gt;142 26/12/2013&lt;BR /&gt;142 26/10/2015&lt;BR /&gt;142 14/11/2016&lt;BR /&gt;143 26/09/2012&lt;BR /&gt;143 21/09/2013&lt;BR /&gt;144 01/10/2012&lt;BR /&gt;144 12/09/2013&lt;BR /&gt;144 06/03/2015&lt;BR /&gt;145 10/02/2013&lt;BR /&gt;145 01/01/2015&lt;BR /&gt;145 14/11/2016&lt;BR /&gt;146 15/10/2012&lt;BR /&gt;146 19/11/2014&lt;BR /&gt;146 11/11/2015&lt;BR /&gt;146 21/12/2016&lt;BR /&gt;147 23/09/2012&lt;BR /&gt;147 25/08/2014&lt;BR /&gt;147 20/08/2015&lt;BR /&gt;147 30/10/2016&lt;BR /&gt;148 09/08/2013&lt;BR /&gt;148 04/02/2015&lt;BR /&gt;149 14/03/2013&lt;BR /&gt;149 12/12/2014&lt;BR /&gt;149 11/09/2016&lt;BR /&gt;150 31/03/2013&lt;BR /&gt;150 18/03/2014&lt;BR /&gt;150 28/01/2016&lt;BR /&gt;150 07/01/2017&lt;BR /&gt;151 30/04/2013&lt;BR /&gt;151 05/10/2014&lt;BR /&gt;151 27/01/2016&lt;BR /&gt;152 06/09/2013&lt;BR /&gt;153 01/04/2013&lt;BR /&gt;153 18/03/2014&lt;BR /&gt;153 06/10/2015&lt;BR /&gt;153 12/10/2016&lt;BR /&gt;154 14/08/2013&lt;BR /&gt;154 14/10/2015&lt;BR /&gt;156 03/04/2013&lt;BR /&gt;156 30/07/2014&lt;BR /&gt;156 05/10/2015&lt;BR /&gt;156 22/09/2016&lt;BR /&gt;158 06/09/2013&lt;BR /&gt;158 20/07/2015&lt;BR /&gt;158 21/09/2016&lt;BR /&gt;162 24/09/2013&lt;BR /&gt;162 20/11/2014&lt;BR /&gt;162 05/10/2015&lt;BR /&gt;162 24/10/2016&lt;BR /&gt;164 07/12/2013&lt;BR /&gt;165 03/02/2014&lt;BR /&gt;165 11/03/2015&lt;BR /&gt;165 27/08/2016&lt;BR /&gt;167 28/07/2014&lt;BR /&gt;169 28/03/2014&lt;BR /&gt;169 02/10/2015&lt;BR /&gt;169 17/10/2016&lt;BR /&gt;174 10/09/2014&lt;BR /&gt;174 23/02/2017&lt;BR /&gt;176 19/11/2014&lt;BR /&gt;176 05/01/2017&lt;BR /&gt;177 14/09/2014&lt;BR /&gt;177 07/09/2015&lt;BR /&gt;179 14/09/2014&lt;BR /&gt;179 22/08/2015&lt;BR /&gt;183 30/11/2014&lt;BR /&gt;184 20/01/2015&lt;BR /&gt;184 10/03/2016&lt;BR /&gt;185 02/03/2015&lt;BR /&gt;188 16/02/2015&lt;BR /&gt;188 28/10/2016&lt;BR /&gt;189 12/08/2015&lt;BR /&gt;189 24/01/2017&lt;BR /&gt;190 20/03/2015&lt;BR /&gt;190 16/11/2016&lt;BR /&gt;197 28/09/2015&lt;BR /&gt;200 16/12/2016&lt;BR /&gt;202 22/09/2015&lt;BR /&gt;202 30/10/2016&lt;BR /&gt;204 02/10/2015&lt;BR /&gt;204 01/11/2016&lt;BR /&gt;205 01/01/2016&lt;BR /&gt;207 23/03/2016&lt;BR /&gt;209 22/03/2016&lt;BR /&gt;211 19/01/2017&lt;BR /&gt;213 23/01/2017&lt;BR /&gt;216 18/10/2016&lt;BR /&gt;218 17/08/2016&lt;BR /&gt;219 07/01/2017&lt;BR /&gt;222 09/01/2017&lt;BR /&gt;227 11/12/2016&lt;BR /&gt;228 11/10/2016&lt;BR /&gt;230 04/02/2017&lt;BR /&gt;231 01/02/2017&lt;BR /&gt;232 01/10/2016&lt;BR /&gt;311 20/10/2015&lt;BR /&gt;315 30/09/2015&lt;BR /&gt;386 29/01/2009&lt;BR /&gt;415 23/09/2015&lt;BR /&gt;415 10/01/2017&lt;BR /&gt;506 27/09/2015&lt;BR /&gt;506 24/12/2016&lt;BR /&gt;895 26/10/2008&lt;BR /&gt;941 16/08/2008&lt;BR /&gt;946 18/01/2008&lt;BR /&gt;948 01/02/2009&lt;BR /&gt;953 04/01/2008&lt;BR /&gt;962 04/02/2008&lt;BR /&gt;981 08/01/2008&lt;BR /&gt;981 08/03/2009&lt;BR /&gt;982 18/03/2009&lt;BR /&gt;982 30/03/2011&lt;BR /&gt;988 20/01/2008&lt;BR /&gt;988 12/09/2009&lt;BR /&gt;989 23/11/2008&lt;BR /&gt;992 16/10/2008&lt;BR /&gt;995 21/03/2009&lt;BR /&gt;999 05/02/2009&lt;BR /&gt;999 18/12/2010&lt;BR /&gt;1386 10/08/2010&lt;BR /&gt;1386 27/02/2012&lt;BR /&gt;2362 03/12/2008&lt;BR /&gt;2362 09/12/2009&lt;BR /&gt;2821 07/01/2008&lt;BR /&gt;5065 03/10/2015&lt;BR /&gt;5065 25/11/2016&lt;BR /&gt;5167 14/10/2015&lt;BR /&gt;5167 01/11/2016&lt;BR /&gt;5253 27/09/2015&lt;BR /&gt;5254 28/09/2015&lt;BR /&gt;5301 22/09/2015&lt;BR /&gt;5332 24/09/2015&lt;BR /&gt;5332 25/10/2016&lt;BR /&gt;5501 22/03/2017&lt;BR /&gt;7029 11/06/2009&lt;BR /&gt;7124 31/05/2009&lt;BR /&gt;7178 00/00/2009&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has you can see each number on the right represent a single cow, and on the left are the calving dates. There is multiple dates for one single cow and some other individuals only have one date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to calculate the difference or amount of days between each group of dates of one individual cow who present multiple calving dates. Cows who only present one date are excluded. (Ex. Cow 1, Cow 7029, Cow 7124, Cow 7178)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really have no idea what should i do. I will take any advice. &lt;img id="manhappy" class="emoticon emoticon-manhappy" src="https://communities.sas.com/i/smilies/16x16_man-happy.png" alt="Man Happy" title="Man Happy" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 11:04:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-calving-intervals-with-dates-in-columns/m-p/396259#M278123</guid>
      <dc:creator>magician</dc:creator>
      <dc:date>2017-09-15T11:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating calving intervals with dates in columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-calving-intervals-with-dates-in-columns/m-p/396285#M278124</link>
      <description>&lt;P&gt;Sort by cow and calvingdate, and run a data step by cow, using the lag() function and the first. and last. variables:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA A;
INPUT cow  calvingdate :ddmmyy10.;
format calvingdate ddmmyy10.;
DATALINES;
1 15/08/2008
4 02/08/2008
4 13/10/2009
4 13/10/2009
4 21/06/2011
4 17/09/2012
14 30/12/2009
14 16/03/2012
18 01/02/2009
18 19/01/2011
27 18/10/2008
34 02/07/2009
34 29/12/2010
34 31/07/2012
37 11/09/2008
37 29/07/2009
37 24/06/2011
39 10/01/2008
39 02/02/2009
39 10/02/2011
40 11/01/2008
41 15/10/2008
41 21/06/2011
44 04/03/2008
44 22/11/2010
44 27/10/2012
;
run;

proc sort data=a;
by cow calvingdate;
run;

data want;
set a;
by cow;
if not (first.cow and last.cow); * this removes cows with only one observation;
diff = calvingdate - lag(calvingdate);
if first.cow then diff = .;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that I reduced the example data to a size that is sufficient to illustrate the issue.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 11:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-calving-intervals-with-dates-in-columns/m-p/396285#M278124</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-09-15T11:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating calving intervals with dates in columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-calving-intervals-with-dates-in-columns/m-p/396286#M278125</link>
      <description>&lt;P&gt;Just to be sure I understand this correctly, For each cow that has multiple calvingdates, you want the difference between the first and the latest calvingdate?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 11:51:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-calving-intervals-with-dates-in-columns/m-p/396286#M278125</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-09-15T11:51:15Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating calving intervals with dates in columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-calving-intervals-with-dates-in-columns/m-p/396427#M278126</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Just to be sure I understand this correctly, For each cow that has multiple calvingdates, you want the difference between the first and the latest calvingdate?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good question.&amp;nbsp; Or is it that you want to know that cow 4 went about 14 months between birth 1 and 2 (twins?), about 8 months between 2/3 and 4, and about 15 months between 4 and 5 (which is what Kurt's solution does)?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4 02/08/2008&lt;BR /&gt;4 13/10/2009&lt;BR /&gt;4 13/10/2009&lt;BR /&gt;4 21/06/2011&lt;BR /&gt;4 17/09/2012&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 17:11:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-calving-intervals-with-dates-in-columns/m-p/396427#M278126</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2017-09-15T17:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating calving intervals with dates in columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-calving-intervals-with-dates-in-columns/m-p/396439#M278127</link>
      <description>&lt;P&gt;If&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/165243"&gt;@magician&lt;/a&gt;&amp;nbsp;just wants the range between the first and last calf,&amp;nbsp;then the last step in &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;'s program can be converted&amp;nbsp;to the below, which produces one record per cow:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set a;
  by cow;
  if first.cow ^= last.cow;
  diff=dif(calvingdate);
  if last.cow;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The "if first.cow ^= last.cow" will allow only the first and last records from only multi-calf cows.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;The DIF function&amp;nbsp;[dif(x) = x-lag(x)] will&amp;nbsp;generate the difference in dates between the last calf&amp;nbsp;of one cow and the first calf of the next cow.&amp;nbsp; But the subsequent "if last.cow" filter keeps only cases in which the DIFF value is appropriate.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Fri, 15 Sep 2017 17:51:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-calving-intervals-with-dates-in-columns/m-p/396439#M278127</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-09-15T17:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating calving intervals with dates in columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-calving-intervals-with-dates-in-columns/m-p/396523#M278128</link>
      <description>&lt;P&gt;Yes exactly! Thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 16 Sep 2017 01:17:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-calving-intervals-with-dates-in-columns/m-p/396523#M278128</guid>
      <dc:creator>magician</dc:creator>
      <dc:date>2017-09-16T01:17:56Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating calving intervals with dates in columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-calving-intervals-with-dates-in-columns/m-p/396533#M278130</link>
      <description>&lt;P&gt;Thank you!!&lt;BR /&gt;&lt;BR /&gt;You guys are life savers!&lt;/P&gt;</description>
      <pubDate>Sat, 16 Sep 2017 02:55:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-calving-intervals-with-dates-in-columns/m-p/396533#M278130</guid>
      <dc:creator>magician</dc:creator>
      <dc:date>2017-09-16T02:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating calving intervals with dates in columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-calving-intervals-with-dates-in-columns/m-p/396556#M278131</link>
      <description>Hello, sorry for bothering you again, i just got one more question:&lt;BR /&gt;&lt;BR /&gt;If i would like to know the interval of days between each different date for cows with multiple dates (More that 2 dates) what can i do?&lt;BR /&gt;&lt;BR /&gt;Ex.&lt;BR /&gt;Cow Calving date&lt;BR /&gt;4 02/08/2008&lt;BR /&gt;4 13/10/2009&lt;BR /&gt;4 21/06/2011&lt;BR /&gt;4 17/09/2012&lt;BR /&gt;&lt;BR /&gt;What are the interval or range of days between 02/08/2008 and 13/10/2009, and 13/10/2009 to 21/06/2011 and so and so.&lt;BR /&gt;&lt;BR /&gt;What can i do or modify to achieve this?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance btw</description>
      <pubDate>Sat, 16 Sep 2017 09:44:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-calving-intervals-with-dates-in-columns/m-p/396556#M278131</guid>
      <dc:creator>magician</dc:creator>
      <dc:date>2017-09-16T09:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating calving intervals with dates in columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-calving-intervals-with-dates-in-columns/m-p/396571#M278132</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/165243"&gt;@magician&lt;/a&gt; wrote:&lt;BR /&gt;Hello, sorry for bothering you again, i just got one more question:&lt;BR /&gt;&lt;BR /&gt;If i would like to know the interval of days between each different date for cows with multiple dates (More that 2 dates) what can i do?&lt;BR /&gt;&lt;BR /&gt;Ex.&lt;BR /&gt;Cow Calving date&lt;BR /&gt;4 02/08/2008&lt;BR /&gt;4 13/10/2009&lt;BR /&gt;4 21/06/2011&lt;BR /&gt;4 17/09/2012&lt;BR /&gt;&lt;BR /&gt;What are the interval or range of days between 02/08/2008 and 13/10/2009, and 13/10/2009 to 21/06/2011 and so and so.&lt;BR /&gt;&lt;BR /&gt;What can i do or modify to achieve this?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance btw&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Use my code.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Sep 2017 15:52:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-calving-intervals-with-dates-in-columns/m-p/396571#M278132</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-09-16T15:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating calving intervals with dates in columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-calving-intervals-with-dates-in-columns/m-p/396639#M278133</link>
      <description>&lt;P&gt;Oh right!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry i discovered some errors in my data that were conflicting, but now everything works!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!! you guys are great!&lt;/P&gt;</description>
      <pubDate>Sun, 17 Sep 2017 09:15:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-calving-intervals-with-dates-in-columns/m-p/396639#M278133</guid>
      <dc:creator>magician</dc:creator>
      <dc:date>2017-09-17T09:15:39Z</dc:date>
    </item>
  </channel>
</rss>

