<?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 with date and time variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-variable-with-date-and-time-variable/m-p/855592#M37700</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the value is a SAS datetime value, meaning that it is numeric and has, apparently, a datetime18. format then you are looking for two functions. The INTNX function is used to change a value by a given interval&lt;/P&gt;
&lt;P&gt;Intnx('dtday',submission_date,-1,'B') will return the beginning of the previous day (dtday means the interval is a day for a datetime variable), the -1 says "the interval before the submission_date, and the 'B' is return the beginning date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so&lt;/P&gt;
&lt;P&gt;intnx('hour',Intnx('dtday',submission_date,-1,'B'),19) will advance the result 19 hours and return the the datetime you want for comparison.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Jan 2023 16:33:07 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-01-25T16:33:07Z</dc:date>
    <item>
      <title>How to create a variable with date and time variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-variable-with-date-and-time-variable/m-p/855588#M37699</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;After looking at lot of videos and reading through i am struggling to find answer to my query.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS EG 8.3 and looking&amp;nbsp; to create a variable from an existing date and time variable for example variable is submission_date and stores '20Jan2023:15:30:33'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the new variable to look at reports from day before yesterday 19:00 onwards, from the example above if i am running the code on 20th Jan then it should pull up records from 18Jan2023 19:00:00 onwards.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am going to be running this report everyday and need the time fixed from 19:00 but not the date (as should always pull data from day before yesterday 19:00 onwards)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help and guidance will be highly appreciated and apologies for the repetition.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2023 16:07:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-variable-with-date-and-time-variable/m-p/855588#M37699</guid>
      <dc:creator>badnash_2000</dc:creator>
      <dc:date>2023-01-25T16:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a variable with date and time variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-variable-with-date-and-time-variable/m-p/855592#M37700</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the value is a SAS datetime value, meaning that it is numeric and has, apparently, a datetime18. format then you are looking for two functions. The INTNX function is used to change a value by a given interval&lt;/P&gt;
&lt;P&gt;Intnx('dtday',submission_date,-1,'B') will return the beginning of the previous day (dtday means the interval is a day for a datetime variable), the -1 says "the interval before the submission_date, and the 'B' is return the beginning date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so&lt;/P&gt;
&lt;P&gt;intnx('hour',Intnx('dtday',submission_date,-1,'B'),19) will advance the result 19 hours and return the the datetime you want for comparison.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2023 16:33:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-variable-with-date-and-time-variable/m-p/855592#M37700</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-01-25T16:33:07Z</dc:date>
    </item>
  </channel>
</rss>

