<?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 calculate a difference between two days; SAS 9.4 in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/calculate-a-difference-between-two-days-SAS-9-4/m-p/669425#M23203</link>
    <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;I wondering if there is a way to calculate the number of days between first jr test and second test, and between second and third, etc. Knowing that some jrtest will be ".".&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input cow$ jrtest:ddmmyy10. scc;
cards;
daisy 10/7/2017 200
maggy 10/7/2017 120
lily 10/7/2017 98
daisy . 89
maggy 11/8/2017 120
lily 11/8/2017 98
daisy 13/9/2017 102
maggy 13/9/2017 154
lily 13/9/2017 232
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Not sure if it helps, but after that I'm transposin my jrtest and I don't want to keep the dates so I'm going with this&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
format jrtest date9.;
by cow jrtest;
run;

data want;
set have;
by cow jrtest;
retain no_test;
if first.cow then no_test=1;
else no_test+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So, I want to know how many days are between test 1 and test 2, test 2 and test 3 etc.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 15 Jul 2020 12:23:42 GMT</pubDate>
    <dc:creator>Annie_Fréchette</dc:creator>
    <dc:date>2020-07-15T12:23:42Z</dc:date>
    <item>
      <title>calculate a difference between two days; SAS 9.4</title>
      <link>https://communities.sas.com/t5/New-SAS-User/calculate-a-difference-between-two-days-SAS-9-4/m-p/669425#M23203</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;I wondering if there is a way to calculate the number of days between first jr test and second test, and between second and third, etc. Knowing that some jrtest will be ".".&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input cow$ jrtest:ddmmyy10. scc;
cards;
daisy 10/7/2017 200
maggy 10/7/2017 120
lily 10/7/2017 98
daisy . 89
maggy 11/8/2017 120
lily 11/8/2017 98
daisy 13/9/2017 102
maggy 13/9/2017 154
lily 13/9/2017 232
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Not sure if it helps, but after that I'm transposin my jrtest and I don't want to keep the dates so I'm going with this&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
format jrtest date9.;
by cow jrtest;
run;

data want;
set have;
by cow jrtest;
retain no_test;
if first.cow then no_test=1;
else no_test+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So, I want to know how many days are between test 1 and test 2, test 2 and test 3 etc.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 12:23:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/calculate-a-difference-between-two-days-SAS-9-4/m-p/669425#M23203</guid>
      <dc:creator>Annie_Fréchette</dc:creator>
      <dc:date>2020-07-15T12:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: calculate a difference between two days; SAS 9.4</title>
      <link>https://communities.sas.com/t5/New-SAS-User/calculate-a-difference-between-two-days-SAS-9-4/m-p/669429#M23205</link>
      <description>&lt;P&gt;please try&amp;nbsp; the below code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input cow$ jrtest:ddmmyy10. scc;
format jrtest date9.;
cards;
daisy 10/7/2017 200
maggy 10/7/2017 120
lily 10/7/2017 98
daisy . 89
maggy 11/8/2017 120
lily 11/8/2017 98
daisy 13/9/2017 102
maggy 13/9/2017 154
lily 13/9/2017 232
;

proc sort data=have;
by cow jrtest;
run;

data want;
set have;
by cow jrtest;
duration=dif(jrtest);
if first.cow then duration=.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Jul 2020 12:30:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/calculate-a-difference-between-two-days-SAS-9-4/m-p/669429#M23205</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-07-15T12:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: calculate a difference between two days; SAS 9.4</title>
      <link>https://communities.sas.com/t5/New-SAS-User/calculate-a-difference-between-two-days-SAS-9-4/m-p/669441#M23207</link>
      <description>&lt;P&gt;Thanks Jag!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 13:06:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/calculate-a-difference-between-two-days-SAS-9-4/m-p/669441#M23207</guid>
      <dc:creator>Annie_Fréchette</dc:creator>
      <dc:date>2020-07-15T13:06:19Z</dc:date>
    </item>
  </channel>
</rss>

