<?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 SAS Date Time and Date Variables Using %Sysfunc in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-SAS-Date-Time-and-Date-Variables-Using-Sysfunc/m-p/638185#M189767</link>
    <description>&lt;P&gt;Also applying the function DATEPART to a date , i.e. input (somevar, yymmdd10.) is almost certainly not what you you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The datepart function will assume the argument is a datetime value, which is measured in seconds and so the value will be treated quite differently than a date that you already have.&lt;/P&gt;
&lt;PRE&gt;data example;
   x="2019-01-01 00:00:00";
   y= input(x,yymmdd10.);
   put y= date9.;
   z=datepart(y);
   put z= date9.;
run;&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt; has a PDF with much information about dates.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Apr 2020 22:33:24 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-04-07T22:33:24Z</dc:date>
    <item>
      <title>Create SAS Date Time and Date Variables Using %Sysfunc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-SAS-Date-Time-and-Date-Variables-Using-Sysfunc/m-p/638162#M189751</link>
      <description>&lt;P&gt;I am attempting to build a process and to make sure all of my dates are consistent I'm trying to do something like the following. I need these various formats for various data inputs that only accept certain types, so I'm trying to make all my variables be modified with just one change each week.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Start_Date_Time=2019-01-01 00:00:00;
%let End_Date_Time=2020-04-03 00:00:00;
%let Start_Date = %Sysfunc(datepart(%Sysfunc(input(&amp;amp;Start_Date_Time),yymmdd10.)));
%let End_Date = %Sysfunc(datepart(%Sysfunc(input((&amp;amp;End_Date_Time),yymmdd10.)));
%let Begin_Week=%Sysfunc(week(&amp;amp;Start_Date));
%let End_Week=%Sysfunc(week(&amp;amp;End_Date));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;When I do this I get an error that input is not a supported function for %sysfunc, is there an alternate way to get at what I'm trying to do?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 20:55:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-SAS-Date-Time-and-Date-Variables-Using-Sysfunc/m-p/638162#M189751</guid>
      <dc:creator>A_SAS_Man</dc:creator>
      <dc:date>2020-04-07T20:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: Create SAS Date Time and Date Variables Using %Sysfunc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-SAS-Date-Time-and-Date-Variables-Using-Sysfunc/m-p/638165#M189753</link>
      <description>&lt;P&gt;From the online documentation of %sysfunc and functions not allowed:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV class="xis-eDocBody"&gt;
&lt;DIV class="xis-refDictEntry"&gt;
&lt;DIV class="xis-details"&gt;
&lt;DIV id="n13mliyaf5yx0hn10xjxoubcovxz" class="xis-topicContent"&gt;
&lt;DIV id="n0x97dl6jtc5ujn1iowwm5bp8p4m" class="xis-table"&gt;
&lt;TABLE class="tgroup"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="xis-horizontalLeft xis-verticalTop"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="xis-horizontalLeft xis-verticalTop"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="xis-horizontalLeft xis-verticalTop"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;DIV id="p0tode6pui6jh5n1d5jeeamer33v" class="xis-note"&gt;&lt;SPAN class="xis-noteGenText"&gt;Note: &lt;/SPAN&gt;Instead of INPUT and PUT, which are not available with %SYSFUNC and %QSYSFUNC, use INPUTN, INPUTC, PUTN, and PUTC.&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 07 Apr 2020 20:59:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-SAS-Date-Time-and-Date-Variables-Using-Sysfunc/m-p/638165#M189753</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-07T20:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: Create SAS Date Time and Date Variables Using %Sysfunc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-SAS-Date-Time-and-Date-Variables-Using-Sysfunc/m-p/638175#M189758</link>
      <description>&lt;P&gt;What&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;says.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively use a data _null_; step and create the macro variables using call symputx(); This will make your code easier to read.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 22:02:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-SAS-Date-Time-and-Date-Variables-Using-Sysfunc/m-p/638175#M189758</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-04-07T22:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: Create SAS Date Time and Date Variables Using %Sysfunc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-SAS-Date-Time-and-Date-Variables-Using-Sysfunc/m-p/638185#M189767</link>
      <description>&lt;P&gt;Also applying the function DATEPART to a date , i.e. input (somevar, yymmdd10.) is almost certainly not what you you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The datepart function will assume the argument is a datetime value, which is measured in seconds and so the value will be treated quite differently than a date that you already have.&lt;/P&gt;
&lt;PRE&gt;data example;
   x="2019-01-01 00:00:00";
   y= input(x,yymmdd10.);
   put y= date9.;
   z=datepart(y);
   put z= date9.;
run;&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt; has a PDF with much information about dates.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 22:33:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-SAS-Date-Time-and-Date-Variables-Using-Sysfunc/m-p/638185#M189767</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-07T22:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: Create SAS Date Time and Date Variables Using %Sysfunc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-SAS-Date-Time-and-Date-Variables-Using-Sysfunc/m-p/638261#M189796</link>
      <description>&lt;P&gt;I think the problem is with your first two %SYSFUNC calls. You use:&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;%Sysfunc(datepart(%Sysfunc(input(&amp;amp;Start_Date_Time),yymmdd10.)))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which makes "yymmdd10." a parameter for the %SYSFUNC macro function (it will return a value formatted that way), probably read with the BEST32. format (giving an invalid value).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you change it to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Sysfunc(input(&amp;amp;Start_Date_Time,yymmdd10.))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;so that it becomes a parameter for the INPUT function, I think you will get what you want (a SAS date value, which can be used in the next calculations). There is no need to use the DATEPART function, as the YYMMDD10. format will only read the first 10 characters, and convert it to a SAS date value.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2020 08:32:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-SAS-Date-Time-and-Date-Variables-Using-Sysfunc/m-p/638261#M189796</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2020-04-08T08:32:47Z</dc:date>
    </item>
  </channel>
</rss>

