<?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: Find difference between two teradata dates in sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/460066#M116924</link>
    <description>I am really sorry for that. I am still trying to figure out to get difference between two dates using sas for teradata. I am new to sysfunc concept</description>
    <pubDate>Fri, 04 May 2018 14:53:19 GMT</pubDate>
    <dc:creator>suresh123</dc:creator>
    <dc:date>2018-05-04T14:53:19Z</dc:date>
    <item>
      <title>SAS date and teradata dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/459786#M116820</link>
      <description>&lt;P&gt;I have below dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date
01jan17
01feb17
01jun17
30jun17
01apr17
01mar17

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I created new macro to split the dataset based on dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro date_loop(start,end);
%let start=%sysfunc(inputn(&amp;amp;start,anydtdte9.));
%let end=%sysfunc(inputn(&amp;amp;end,anydtdte9.));
%let dif=%sysfunc(intck(month,&amp;amp;start,&amp;amp;end));
%do i=0 %to &amp;amp;dif;
%let date=%sysfunc(putn(%sysfunc(intnx(month,&amp;amp;start,&amp;amp;i,b),yymmn6.));
proc sql;
create table new&amp;amp;date. as select 8 from new where date=&amp;amp;start.; quit;
%put &amp;amp;date &amp;amp;dif;
%end;
%mend;

%date_loop;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The above code is working fine in SAS EG but its not working it it is accessing teradata dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example; dates for start is 2017-01-01 and end 2017-06-01.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to handle date function in above code it is teradata.&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 18:14:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/459786#M116820</guid>
      <dc:creator>suresh123</dc:creator>
      <dc:date>2018-05-03T18:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: SAS date and teradata dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/459815#M116828</link>
      <description>&lt;P&gt;Most database store date values as Datetime, so first check how your date values from teradata are returned in SAS. If your teradata table is very large just for test get only few rows (Obs=10). Then if it is datetime then you need to change your where clause to DATEPART(teradata_datetime)=&amp;amp;start.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 19:38:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/459815#M116828</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-05-03T19:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: SAS date and teradata dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/459819#M116831</link>
      <description>&lt;P&gt;Dates need to be specified in the date literal format, not YYMMN6 like you're requesting UNLESS the field in Teradata is a character.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So make sure your macro variable resolves to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;'01Jun2017'd or something like that. The quotes are required, you can either include them in the macro variable or in the code when resolving the macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date=%sysfunc(putn(%sysfunc(intnx(month,&amp;amp;start,&amp;amp;i,b)));&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 May 2018 19:47:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/459819#M116831</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-03T19:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: SAS date and teradata dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/459912#M116859</link>
      <description>&lt;P&gt;You need to create macro variable as shown below. because for teradata to understand date it needs to be in quote&amp;nbsp;as 'YYYY-MM-DD'. An example is shown below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start_dt = '2017-07-01';
%let end_dt = '2017-07-31';
proc sql;
connect to teradata (server=myserver user=myuserid pw=mypass);
execute(create table edwwrkuser.staging_customer as
select * from edwwrkuser.Cusomter table
where create_dt between &amp;amp;start_dt and &amp;amp;enddate) with data primary index(cust_id)) by teradata;
execute(commit work) by Teradata;
disconnect from teradata;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 03:17:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/459912#M116859</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2018-05-04T03:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: SAS date and teradata dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/459948#M116865</link>
      <description>&lt;P&gt;If that is the case, how to find difference between two teradata dates in sas like&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let a='2017-01-01';&lt;/P&gt;&lt;P&gt;%let b=&lt;STRONG&gt;&lt;SPAN&gt;'2017-12-01';&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 06:41:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/459948#M116865</guid>
      <dc:creator>suresh123</dc:creator>
      <dc:date>2018-05-04T06:41:17Z</dc:date>
    </item>
    <item>
      <title>Find difference between two teradata dates in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/460055#M116919</link>
      <description>&lt;P&gt;Iam completely new to teradata dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two teradata dates and trying to the no of months between them&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%let a='2017-01-01';
%let b='2017-12-01';


%let days = %sysfunc(intck(month,&amp;amp;a.,&amp;amp;b.));
%put days;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the error&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;ERROR: Argument 2 to function INTCK referenced by the %SYSFUNC or %QSYSFUNC macro function is not a number.
ERROR: Argument 3 to function INTCK referenced by the %SYSFUNC or %QSYSFUNC macro function is not a number.
ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC argument list.  Execution of %SYSCALL statement or %SYSFUNC 
    or %QSYSFUNC function reference is terminated.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 May 2018 14:34:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/460055#M116919</guid>
      <dc:creator>suresh123</dc:creator>
      <dc:date>2018-05-04T14:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: Find difference between two teradata dates in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/460058#M116920</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/207177"&gt;@suresh123&lt;/a&gt;&amp;nbsp;Good morning, I have feeling you probably haven't read what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp; explained as a response to the thread&amp;nbsp; &lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/SAS-date-issue/m-p/459794" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/SAS-date-issue/m-p/459794&lt;/A&gt; initiated by you. If you get the grasp of their explanation, you will know why. Please refer to the thread again.&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 14:40:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/460058#M116920</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-04T14:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: Find difference between two teradata dates in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/460060#M116921</link>
      <description>&lt;P&gt;You could acknowledge help as a matter of basic courtesy when people take their time to offer their help, which you haven't&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 14:44:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/460060#M116921</guid>
      <dc:creator>MarkWik</dc:creator>
      <dc:date>2018-05-04T14:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: Find difference between two teradata dates in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/460062#M116922</link>
      <description>Thanks novinosrin. I will look into it.</description>
      <pubDate>Fri, 04 May 2018 14:52:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/460062#M116922</guid>
      <dc:creator>suresh123</dc:creator>
      <dc:date>2018-05-04T14:52:05Z</dc:date>
    </item>
    <item>
      <title>Re: Find difference between two teradata dates in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/460064#M116923</link>
      <description>&lt;P&gt;Doesn't seem to have anything to do with teradata?&amp;nbsp; You have created two macro variables - which are strings - this string data is used in the intck function which is expecting two numeric date items, hence you get the error that the strings you pass are not numeric.&amp;nbsp; Now you could do if you changed your date format as only date9 is valid for literals:&lt;/P&gt;
&lt;PRE&gt;%let a='01JAN2017'd;
&lt;/PRE&gt;
&lt;P&gt;So that will when put into the intck be treated as a date literal and be converted to a numeric date value.&amp;nbsp; It is however rarely a good idea to be putting - dates or quotes into macro variables, adn then using date functions on strings.&amp;nbsp; If you want the days between:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  call symputx('days',intck('month',input('2017-01-01',yymmdd10.),input('2017-12-01',yymmdd10.)));
run;
&lt;/PRE&gt;
&lt;P&gt;Really need more info on what your doing, is this pass through to the database, if so teradata has date compare functions does in not?&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 14:52:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/460064#M116923</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-04T14:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: Find difference between two teradata dates in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/460066#M116924</link>
      <description>I am really sorry for that. I am still trying to figure out to get difference between two dates using sas for teradata. I am new to sysfunc concept</description>
      <pubDate>Fri, 04 May 2018 14:53:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/460066#M116924</guid>
      <dc:creator>suresh123</dc:creator>
      <dc:date>2018-05-04T14:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: SAS date and teradata dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/460070#M116916</link>
      <description>&lt;P&gt;Are you using SQL Pass through or PROC SQL. If you're using SQL Pass through you have to specify the dates in the tera data format. If you're using PROC SQL you need to use SAS date literals.&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37783"&gt;@kiranv_&lt;/a&gt;&amp;nbsp;answer is assuming SQL Pass through.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to find the difference you'd first have to remove quotes, read it in as dates, then take the difference using INTNX. Do you have control over how the macro variables are created? If you do, the simplest solution is to specify it in Date9 literal format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 15:03:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/460070#M116916</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-04T15:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: Find difference between two teradata dates in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/460075#M116925</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/207177"&gt;@suresh123&lt;/a&gt;&amp;nbsp;read the answer I just posted in the previous thread. I'll merge these threads since the topic is the same and its confusing now.&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 15:08:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-and-teradata-dates/m-p/460075#M116925</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-04T15:08:11Z</dc:date>
    </item>
  </channel>
</rss>

