<?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: Create a time variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-time-variable/m-p/192748#M266220</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What exactly does "however, it does not seem to be working correctly" mean? Values out of expected range? Sign incorrect? Format incorrect?&lt;/P&gt;&lt;P&gt;Provide some expected "correct" results.&lt;/P&gt;&lt;P&gt;What you have calculated are intervals in days. Is that what you want?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Dec 2014 18:21:09 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2014-12-03T18:21:09Z</dc:date>
    <item>
      <title>Create a time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-time-variable/m-p/192745#M266217</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have 3 visits worth of data and I need to calculate time elapsed since last visit. Each of the visits have a date for when the interview was conducted. I am subtracting those dates to come up with the number of days between the interviews, however, it does not seem to be working correctly. My code is below and attached is a screenshot of the output. Suggestions as to how to fix the calculation would be greatly appreciated&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Screen Shot 2014-12-02 at 8.29.40 PM.png" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/8142_Screen Shot 2014-12-02 at 8.29.40 PM.png" width="450" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #000000; font-family: Helvetica; font-size: 12px;"&gt;&lt;/P&gt;&lt;DIV style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; visit2clean_sn;&lt;SPAN style="line-height: 1.5em; color: #0433ff;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="line-height: 1.5em;"&gt; visit2clean_s;&lt;/SPAN&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;time=today6m-today();&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;STRONG style="color: #011993; line-height: 1.5em;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="line-height: 1.5em; color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;/P&gt;&lt;DIV&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; visit3clean_s;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0433ff;"&gt;set&lt;/SPAN&gt; visit3clean_s;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0433ff;"&gt;if&lt;/SPAN&gt; today6m^=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;then&lt;/SPAN&gt; time=today12m-today6m;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0433ff;"&gt;else&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;if&lt;/SPAN&gt; today6m=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;then&lt;/SPAN&gt; time=today12m-today();&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 04:57:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-time-variable/m-p/192745#M266217</guid>
      <dc:creator>rfarmenta</dc:creator>
      <dc:date>2014-12-03T04:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create a time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-time-variable/m-p/192746#M266218</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well at an initial view you use a variable today12m which is not in the data you post above, it should be today.&amp;nbsp; You also don't need the else if:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0433ff;"&gt;if&lt;/SPAN&gt; today6m^=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;then&lt;/SPAN&gt; time=today12m-today6m;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0433ff;"&gt;else&lt;/SPAN&gt; time=today-today();&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 09:23:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-time-variable/m-p/192746#M266218</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-12-03T09:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: Create a time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-time-variable/m-p/192747#M266219</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are two separate sets of code, one of the 6 month visit and one for the 12 month visit. I only provided sample output from the first code, attached here is the output from the second set of code but it isn't much different that I can see. &lt;IMG alt="Screen Shot 2014-12-03 at 9.47.22 AM.png" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/8186_Screen Shot 2014-12-03 at 9.47.22 AM.png" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 17:48:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-time-variable/m-p/192747#M266219</guid>
      <dc:creator>rfarmenta</dc:creator>
      <dc:date>2014-12-03T17:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: Create a time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-time-variable/m-p/192748#M266220</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What exactly does "however, it does not seem to be working correctly" mean? Values out of expected range? Sign incorrect? Format incorrect?&lt;/P&gt;&lt;P&gt;Provide some expected "correct" results.&lt;/P&gt;&lt;P&gt;What you have calculated are intervals in days. Is that what you want?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 18:21:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-time-variable/m-p/192748#M266220</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-12-03T18:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: Create a time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-time-variable/m-p/192749#M266221</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I believe the values and signs are incorrect for some of the calculations but I could be reading the output incorrectly. In the output I posted today, obs 242, time= -49 but the difference between today12m and today is much greater than that. Is the negative value how SAS calculates time spans greater than 1 year? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This new variable will be the time covariate in a longitudinal analysis.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 18:30:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-time-variable/m-p/192749#M266221</guid>
      <dc:creator>rfarmenta</dc:creator>
      <dc:date>2014-12-03T18:30:41Z</dc:date>
    </item>
    <item>
      <title>Re: Create a time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-time-variable/m-p/192750#M266222</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just for giggles, what do you see in the log if you run:&lt;/P&gt;&lt;P&gt;%put %sysfunc(today());&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 18:42:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-time-variable/m-p/192750#M266222</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-12-03T18:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: Create a time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-time-variable/m-p/192751#M266223</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think I just figured out the problem actually, I remove the parenthesis from the end of today() and the calculations are correct. Now I am not sure what the parenthesis actually do and probably didn't need them in the first place. Attached in what I get in my log when I run the code above, thank you for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Screen Shot 2014-12-03 at 10.45.30 AM.png" class="jive-image" src="https://communities.sas.com/legacyfs/online/8187_Screen Shot 2014-12-03 at 10.45.30 AM.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 18:47:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-time-variable/m-p/192751#M266223</guid>
      <dc:creator>rfarmenta</dc:creator>
      <dc:date>2014-12-03T18:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: Create a time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-time-variable/m-p/192752#M266224</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Today() is a FUNCTION that calls todays date from the computer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 20:12:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-time-variable/m-p/192752#M266224</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-12-03T20:12:30Z</dc:date>
    </item>
  </channel>
</rss>

