<?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: How to create a Variable that measures the time difference between two variables? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-Variable-that-measures-the-time-difference/m-p/478648#M123451</link>
    <description>&lt;P&gt;Subtract the two dates from each other or use the &lt;A href="http://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p1md4mx2crzfaqn14va8kt7qvfhr.htm&amp;amp;docsetVersion=3.1&amp;amp;locale=ko" target="_self"&gt;INTCK Function&lt;/A&gt;&amp;nbsp;to measure how many specified intervals there are between two dates like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
days=intck('day','01jan2009'd,'01jan2018'd);
weeks=intck('week','01jan2009'd,'01jan2018'd);
months=intck('month','01jan2009'd,'01jan2018'd);
years=intck('year','01jan2009'd,'01jan2018'd);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Jul 2018 13:48:18 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2018-07-17T13:48:18Z</dc:date>
    <item>
      <title>How to create a Variable that measures the time difference between two variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-Variable-that-measures-the-time-difference/m-p/478647#M123450</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data patients1; 
set patients;
format authorisation ddmmyy10.;
if NIS_Nummer in (2628,3078,6791) then authorisation='11Jan2008'd;
if NIS_Nummer in (2408) then authorisation='28Aug2007'd;
if NIS_Nummer in (6759) then authorisation='18Sep2014'd;
if NIS_Nummer in (2311,5361,6887) then authorisation="23Apr2007"d;
if NIS_Nummer in (6687) then authorisation="03Aug2009"d;
if NIS_Nummer in (6667) then authorisation="27May2015"d;
run;

data datensatz_pms; 
set datensatz_pms;
format n_date ddmmyy10.;
n_date = input(notificationdate,ddmmyy10.);
if '01jan2013'd &amp;lt;= n_date &amp;lt;= '31dec2013'd then year=2013;
if '01jan2014'd &amp;lt;= n_date &amp;lt;= '31dec2014'd then year=2014;
if '01jan2015'd &amp;lt;= n_date &amp;lt;= '31dec2015'd then year=2015;
if '01jan2016'd &amp;lt;= n_date &amp;lt;= '31dec2016'd then year=2016;
if '01jan2017'd &amp;lt;= n_date &amp;lt;= '31dec2017'd then year=2017;
run;                                                    &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Dear community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for your instant support when i am struggeling with sas.&lt;/P&gt;&lt;P&gt;I need your help again.&lt;/P&gt;&lt;P&gt;Now I have to measure the difference between two date Variables (notification date and authorisation date) and if the time difference between the authorisation date and the notification date is shorter than 2 years I its a newly authorised drug and if the time difference is longer than 2 years its not a newly authorised drug. I need Sas to create me a new variable with that information(newly authorised: yeys/no). But how to create this variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really need your support with this as I have absolutely no idea^^&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 13:49:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-Variable-that-measures-the-time-difference/m-p/478647#M123450</guid>
      <dc:creator>marysmith</dc:creator>
      <dc:date>2018-07-17T13:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Variable that measures the time difference between two variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-Variable-that-measures-the-time-difference/m-p/478648#M123451</link>
      <description>&lt;P&gt;Subtract the two dates from each other or use the &lt;A href="http://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p1md4mx2crzfaqn14va8kt7qvfhr.htm&amp;amp;docsetVersion=3.1&amp;amp;locale=ko" target="_self"&gt;INTCK Function&lt;/A&gt;&amp;nbsp;to measure how many specified intervals there are between two dates like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
days=intck('day','01jan2009'd,'01jan2018'd);
weeks=intck('week','01jan2009'd,'01jan2018'd);
months=intck('month','01jan2009'd,'01jan2018'd);
years=intck('year','01jan2009'd,'01jan2018'd);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 13:48:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-Variable-that-measures-the-time-difference/m-p/478648#M123451</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-07-17T13:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Variable that measures the time difference between two variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-Variable-that-measures-the-time-difference/m-p/478649#M123452</link>
      <description>&lt;P&gt;You subtract one date from the other. This assumes your variables are SAS date values. Then you can see if that value is &amp;gt;730 (which is two years in days).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need more details, you have to provide more details, and show us a small portion of the relevant data.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 13:45:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-Variable-that-measures-the-time-difference/m-p/478649#M123452</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-17T13:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Variable that measures the time difference between two variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-Variable-that-measures-the-time-difference/m-p/478654#M123454</link>
      <description>Thank you!&lt;BR /&gt;But how to substract those two variables? What information do you need?&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Jul 2018 13:53:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-Variable-that-measures-the-time-difference/m-p/478654#M123454</guid>
      <dc:creator>marysmith</dc:creator>
      <dc:date>2018-07-17T13:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Variable that measures the time difference between two variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-Variable-that-measures-the-time-difference/m-p/478655#M123455</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dates;
date1='01jan2009'd;
date2='01jan2018'd;
daysbetween=date2-date1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Jul 2018 13:55:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-Variable-that-measures-the-time-difference/m-p/478655#M123455</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-07-17T13:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Variable that measures the time difference between two variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-Variable-that-measures-the-time-difference/m-p/478656#M123456</link>
      <description>How do I use it with those two variables?&lt;BR /&gt;Like this?&lt;BR /&gt;data patients_new;&lt;BR /&gt;set patients&lt;BR /&gt;days=intck('authorisationdate', '01aug2011'd,'notificationdate' '01feb2012'd);&lt;BR /&gt;put days=;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Jul 2018 13:57:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-Variable-that-measures-the-time-difference/m-p/478656#M123456</guid>
      <dc:creator>marysmith</dc:creator>
      <dc:date>2018-07-17T13:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Variable that measures the time difference between two variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-Variable-that-measures-the-time-difference/m-p/478657#M123457</link>
      <description>Oh yeah that was easy^^ thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Jul 2018 13:58:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-Variable-that-measures-the-time-difference/m-p/478657#M123457</guid>
      <dc:creator>marysmith</dc:creator>
      <dc:date>2018-07-17T13:58:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Variable that measures the time difference between two variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-Variable-that-measures-the-time-difference/m-p/478659#M123458</link>
      <description>&lt;P&gt;No. If you have two date variables, lets say date1 and date2 in a data set like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dates;
date1='01jan2009'd;
date2='01jan2018'd;
format date: date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and you want to calculate the difference between them, measured in years, do like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set dates;
   yearsbetween=intck('year',date1,date2);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Change the first argument in the INTCK Function to day, week, month or whatever interval you want to measure.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 14:02:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-Variable-that-measures-the-time-difference/m-p/478659#M123458</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-07-17T14:02:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Variable that measures the time difference between two variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-Variable-that-measures-the-time-difference/m-p/478661#M123460</link>
      <description>Ok thanks! But I already have the 2 variables with the dates for all 260 cases. My dataset looks like that. And now I need sas to substrate those two dates for all 260 cases and create me a new variable (new_authorised:0/1)&lt;BR /&gt;Number authorization notificationdate new_auth&lt;BR /&gt;1 12/02/2008 10/05/2014 0&lt;BR /&gt;2 15/06/2004 02/02/2015 0&lt;BR /&gt;3 07/08/2013 21/10/2014 1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Jul 2018 14:11:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-Variable-that-measures-the-time-difference/m-p/478661#M123460</guid>
      <dc:creator>marysmith</dc:creator>
      <dc:date>2018-07-17T14:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Variable that measures the time difference between two variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-Variable-that-measures-the-time-difference/m-p/478664#M123461</link>
      <description>&lt;P&gt;Are these actually SAS dates in your data set, or are the character strings? Are the variables character or numeric?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 14:15:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-Variable-that-measures-the-time-difference/m-p/478664#M123461</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-17T14:15:40Z</dc:date>
    </item>
  </channel>
</rss>

