<?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: SAS macro variable with many datetime values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-variable-with-many-datetime-values/m-p/464780#M118517</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/153636"&gt;@aleksi555&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;Is it possible to set more than one datetime values&amp;nbsp;into %let-function? Below is query which works but there are only one "date" and one "endingdate". Is it possible to have list of two or more datetimes and get result for each "pair" into one table?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;let% date=&lt;FONT face="Courier New"&gt;&amp;nbsp;'1apr2015:00:00:00.001'DT;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;let% endingdate= '31mar2018:00:00:00.001'DT;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;create&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;test &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;variable1, &amp;amp;date.,&lt;FONT face="Courier New"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;endingdate.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; table1&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;where&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;FONT color="#333333" face="Helvetica" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;date1 &amp;gt;= &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;date.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;date1 &amp;lt;= &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;endingdate.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You should provide some example data of the input and the desired output.&lt;/P&gt;
&lt;P&gt;If you have multiple values of anything in a single macro variable you will not be able to use statements such as&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;date1 &amp;gt;= &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;date.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" face="Courier New" size="3"&gt;but would have to build code to the proper compound comparison for multiple values. Without knowing what you might mean with that comparison I'm not going to attempt to guess at this point. Equal comparisons are easier as you can use an IN operator but there is not equivalent for &amp;lt; or &amp;gt; comparisons. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" face="Courier New" size="3"&gt;As a minimum you might have to delve in to macro programing to build the proper comparisons. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" face="Courier New" size="3"&gt;Better might be to build a data set, join it and compare that way. But again without a more concrete example of input and desired result it is hard to be more specific.&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 24 May 2018 14:41:15 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-05-24T14:41:15Z</dc:date>
    <item>
      <title>SAS macro variable with many datetime values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-variable-with-many-datetime-values/m-p/464770#M118510</link>
      <description>&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;Is it possible to set more than one datetime values&amp;nbsp;into %let-function? Below is query which works but there are only one "date" and one "endingdate". Is it possible to have list of two or more datetimes and get result for each "pair" into one table?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;let% date=&lt;FONT face="Courier New"&gt;&amp;nbsp;'1apr2015:00:00:00.001'DT;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;let% endingdate= '31mar2018:00:00:00.001'DT;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;create&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;test &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;variable1, &amp;amp;date.,&lt;FONT face="Courier New"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;endingdate.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; table1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;where&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;FONT color="#333333" face="Helvetica" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;date1 &amp;gt;= &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;date.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;date1 &amp;lt;= &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;endingdate.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 14:21:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-variable-with-many-datetime-values/m-p/464770#M118510</guid>
      <dc:creator>aleksi555</dc:creator>
      <dc:date>2018-05-24T14:21:04Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro variable with many datetime values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-variable-with-many-datetime-values/m-p/464778#M118515</link>
      <description>&lt;P&gt;Sure possible by concatenating with a delimiter. What is your expected output or requirement. Samples of your input and wanted output makes it easy for responders to give you a precise solution. Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 14:35:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-variable-with-many-datetime-values/m-p/464778#M118515</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-24T14:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro variable with many datetime values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-variable-with-many-datetime-values/m-p/464780#M118517</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/153636"&gt;@aleksi555&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;Is it possible to set more than one datetime values&amp;nbsp;into %let-function? Below is query which works but there are only one "date" and one "endingdate". Is it possible to have list of two or more datetimes and get result for each "pair" into one table?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;let% date=&lt;FONT face="Courier New"&gt;&amp;nbsp;'1apr2015:00:00:00.001'DT;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;let% endingdate= '31mar2018:00:00:00.001'DT;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;create&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;test &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;variable1, &amp;amp;date.,&lt;FONT face="Courier New"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;endingdate.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; table1&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;where&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;FONT color="#333333" face="Helvetica" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;date1 &amp;gt;= &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;date.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;date1 &amp;lt;= &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;endingdate.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You should provide some example data of the input and the desired output.&lt;/P&gt;
&lt;P&gt;If you have multiple values of anything in a single macro variable you will not be able to use statements such as&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;date1 &amp;gt;= &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;date.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" face="Courier New" size="3"&gt;but would have to build code to the proper compound comparison for multiple values. Without knowing what you might mean with that comparison I'm not going to attempt to guess at this point. Equal comparisons are easier as you can use an IN operator but there is not equivalent for &amp;lt; or &amp;gt; comparisons. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" face="Courier New" size="3"&gt;As a minimum you might have to delve in to macro programing to build the proper comparisons. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" face="Courier New" size="3"&gt;Better might be to build a data set, join it and compare that way. But again without a more concrete example of input and desired result it is hard to be more specific.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 14:41:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-variable-with-many-datetime-values/m-p/464780#M118517</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-05-24T14:41:15Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro variable with many datetime values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-variable-with-many-datetime-values/m-p/464783#M118519</link>
      <description>Hi, thanks for your message. I would like the output as follows: consider %let "date" would contain datetimes: date1 and date2.&lt;BR /&gt;Also %let "endingdate" contains endingdate1 and endingdate2 values. Now i want the query to run first with values "date1" and "endingdate1" and after that with "date2" and "endingdate2". At the end id have "variable1" values along with these two date combinations all in one table.</description>
      <pubDate>Thu, 24 May 2018 14:44:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-variable-with-many-datetime-values/m-p/464783#M118519</guid>
      <dc:creator>aleksi555</dc:creator>
      <dc:date>2018-05-24T14:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro variable with many datetime values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-variable-with-many-datetime-values/m-p/464790#M118522</link>
      <description>&lt;P&gt;What ever information we have so far I can suggest following,&lt;BR /&gt;&lt;BR /&gt;-Create DATE Array&lt;BR /&gt;Then&lt;BR /&gt;-Iterate using loop.&lt;BR /&gt;Hope that helps&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Date dataset should b like that to create an array&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date1&lt;/TD&gt;&lt;TD&gt;Date2&lt;/TD&gt;&lt;TD&gt;dateN&lt;/TD&gt;&lt;TD&gt;Enddate1&lt;/TD&gt;&lt;TD&gt;Enddate2&lt;/TD&gt;&lt;TD&gt;EnddateN&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;21/05/2018&lt;/TD&gt;&lt;TD&gt;22/05/2018&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;23/05/2018&lt;/TD&gt;&lt;TD&gt;24/05/2018&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a sample code. you have to make changes as per your dataset&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;array date[n];&lt;BR /&gt;array enddate[n];&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Do&amp;nbsp; i=1 to n;&lt;/P&gt;&lt;P&gt;&amp;nbsp;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;create table test as&lt;BR /&gt;&amp;nbsp;select&amp;nbsp; variable1, &amp;amp;date.,&amp;amp;endingdate.&lt;BR /&gt;&amp;nbsp;from table1&lt;BR /&gt;&amp;nbsp;where&lt;BR /&gt;&amp;nbsp;date[n] &amp;gt;= &amp;amp;date.&lt;BR /&gt;&amp;nbsp;and date[n] &amp;lt;= &amp;amp;endingdate.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;;quit;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 15:09:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-variable-with-many-datetime-values/m-p/464790#M118522</guid>
      <dc:creator>emrancaan</dc:creator>
      <dc:date>2018-05-24T15:09:12Z</dc:date>
    </item>
  </channel>
</rss>

