<?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: Sysfunc Date9 with Select Into: in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569679#M160575</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date1=%sysfunc(today());
%put &amp;amp;=date1;  %* raw value ;

%let date2=%sysfunc(today(),date9.);
%put &amp;amp;=date2;  %* formatted value ;

* use in a data step ;
data test2;
   date1=&amp;amp;date1;
   date2="&amp;amp;date2"d;
   format _all_ date9.;
run;

* using proc sql ;
* (do you even need proc sql if %let + %sysfunc() meets your needs)? ;
proc sql noprint;
   select today()
         ,today()
         ,today() format=date9.
         ,datetime() format=dtdate9.
         into
          :date3
         ,:date4 trimmed
         ,:date5 
         ,:date6
   from  sashelp.class(obs=1);
quit;

%put date3=***&amp;amp;date3***;
%put date4=###&amp;amp;date4***;
%put &amp;amp;=date5;
%put &amp;amp;=date6;

* use in a data step ;
data test2;
   date3=&amp;amp;date3;
   date4=&amp;amp;date4;
   date5="&amp;amp;date5"d;
   date6="&amp;amp;date6"d;
   format _all_ date9.;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 28 Jun 2019 00:42:54 GMT</pubDate>
    <dc:creator>ScottBass</dc:creator>
    <dc:date>2019-06-28T00:42:54Z</dc:date>
    <item>
      <title>Sysfunc Date9 with Select Into:</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569627#M160551</link>
      <description>&lt;P&gt;How do you do the same thing as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;date=%sysfunc(today(),date9);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With a select into:&amp;nbsp; ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;select %sysfunc(year10_Date, date9) into :date separated by ''&lt;BR /&gt;from my_table&lt;BR /&gt;where curr_year_date = today();&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried syntax:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;select year10_Date format=date9. into :date separated by ''&lt;BR /&gt;from mytable&lt;BR /&gt;where curr_year_date = today();&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 20:57:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569627#M160551</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2019-06-27T20:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Sysfunc Date9 with Select Into:</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569638#M160553</link>
      <description>&lt;P&gt;If you need the dates for comparisons or selections, you don't need formats, just use the raw values.&lt;/P&gt;
&lt;P&gt;Otherwise use SAS functions:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select put(year10_Date, date9.) into :date separated by ' '
from my_table
where curr_year_date = today();
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Jun 2019 20:59:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569638#M160553</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-27T20:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: Sysfunc Date9 with Select Into:</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569639#M160554</link>
      <description>&lt;P&gt;Kurt,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like that code should work.&amp;nbsp; Oddly when I used your code I received the message&amp;nbsp;ERROR: Date value out of range.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 21:02:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569639#M160554</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2019-06-27T21:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: Sysfunc Date9 with Select Into:</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569642#M160555</link>
      <description>&lt;P&gt;Check if the variable is really a SAS date, or if it just looks like one.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 21:04:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569642#M160555</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-27T21:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: Sysfunc Date9 with Select Into:</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569643#M160556</link>
      <description>&lt;P&gt;today() is a function&amp;nbsp; (SAS and Oracle)&lt;/P&gt;
&lt;P&gt;Date is being created in the select.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 21:06:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569643#M160556</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2019-06-27T21:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: Sysfunc Date9 with Select Into:</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569657#M160563</link>
      <description>&lt;P&gt;The %SYSFUNC() macro function lets you call regular SAS function in macro code.&amp;nbsp; So your first call&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%sysfunc(today(),date9)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is generating todays date and formatting it using DATE9 format.&amp;nbsp; So that should result in a stream of characters that looks like&lt;/P&gt;
&lt;PRE&gt;27JUN2019&lt;/PRE&gt;
&lt;P&gt;You could use that in a %LET statement like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date=%sysfunc(today(),date9);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But you couldn't use that in a regular SAS statement like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date=%sysfunc(today(),date9);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;because syntax like&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date=27JUN2019;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is not valid.&amp;nbsp; You need to either add quotes to make it a character literal or quotes and the letter D to make it a date literal.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your first SQL statement is just gibberish because to the %SYSFUNC() macro function the string YEAR10_DATE is not a valid date value.&amp;nbsp; It is looking for a value like "27JUN2019"d or 21727.&amp;nbsp; And anyway it will just be a constant to SQL so even if you got the macro function to work you would generate the same value over and over again for every observation read.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your second one looks a little better. In that one you are actually referencing a variable in the dataset. Not sure why you want to smush them together without any delimiter between them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it complained that the values didn't work for the format then the variable YEAR10_DATE does not have date values.&amp;nbsp; It might have datetime values in which case you could use the DTDATE9. format instead.&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;</description>
      <pubDate>Thu, 27 Jun 2019 22:25:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569657#M160563</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-27T22:25:01Z</dc:date>
    </item>
    <item>
      <title>Re: Sysfunc Date9 with Select Into:</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569660#M160565</link>
      <description>&lt;PRE&gt;proc sql;
select put(year10_Date, date9) into :date separated by ''
from my_table
where curr_year_date = today();
quit;&lt;/PRE&gt;
&lt;P&gt;should work.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 22:36:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569660#M160565</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-06-27T22:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: Sysfunc Date9 with Select Into:</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569663#M160567</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/5059"&gt;@DavidPhillips2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;today() is a function&amp;nbsp; (SAS and Oracle)&lt;/P&gt;
&lt;P&gt;Date is being created in the select.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I was talking about&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;year10_Date&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;This seems to not be a SAS date variable.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 22:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569663#M160567</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-27T22:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: Sysfunc Date9 with Select Into:</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569672#M160570</link>
      <description>If it's a database, it's like datetime</description>
      <pubDate>Fri, 28 Jun 2019 00:00:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569672#M160570</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-28T00:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: Sysfunc Date9 with Select Into:</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569679#M160575</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date1=%sysfunc(today());
%put &amp;amp;=date1;  %* raw value ;

%let date2=%sysfunc(today(),date9.);
%put &amp;amp;=date2;  %* formatted value ;

* use in a data step ;
data test2;
   date1=&amp;amp;date1;
   date2="&amp;amp;date2"d;
   format _all_ date9.;
run;

* using proc sql ;
* (do you even need proc sql if %let + %sysfunc() meets your needs)? ;
proc sql noprint;
   select today()
         ,today()
         ,today() format=date9.
         ,datetime() format=dtdate9.
         into
          :date3
         ,:date4 trimmed
         ,:date5 
         ,:date6
   from  sashelp.class(obs=1);
quit;

%put date3=***&amp;amp;date3***;
%put date4=###&amp;amp;date4***;
%put &amp;amp;=date5;
%put &amp;amp;=date6;

* use in a data step ;
data test2;
   date3=&amp;amp;date3;
   date4=&amp;amp;date4;
   date5="&amp;amp;date5"d;
   date6="&amp;amp;date6"d;
   format _all_ date9.;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Jun 2019 00:42:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569679#M160575</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-06-28T00:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: Sysfunc Date9 with Select Into:</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569683#M160576</link>
      <description>&lt;P&gt;Find the maximum value that you are trying to select.&amp;nbsp; If you divide that by 365, you will see approximately how many years into the future that number represents, as a date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As others have hinted, it is possible you are pulling datetime values instead of date values.&amp;nbsp; The SAS date scale only goes up to the year 20,000 so datetime values might be too large to be interpreted as a date.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2019 01:47:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/569683#M160576</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-06-28T01:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: Sysfunc Date9 with Select Into:</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/570236#M160781</link>
      <description>&lt;P&gt;I have a date time so datepart() is needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;select put(datepart(var1), date9.) into :Date separated by ' '&lt;BR /&gt;from mytable&lt;BR /&gt;where datepart(curr_year_date) = today();&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2019 13:43:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sysfunc-Date9-with-Select-Into/m-p/570236#M160781</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2019-07-01T13:43:08Z</dc:date>
    </item>
  </channel>
</rss>

