<?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: Trying to create a table from Teradata using SAS macros. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838708#M331620</link>
    <description>If you can't post the logs, makes sure to set the macro debugging options on and run it in each set up and compare the two logs to see where they're different. &lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 14 Oct 2022 19:28:05 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-10-14T19:28:05Z</dc:date>
    <item>
      <title>Trying to create a table from Teradata using SAS macros.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838692#M331608</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I am trying to create a dates table for every 3 months, when i am using the below code within Rsubmit the &lt;CODE class=" language-sas"&gt;datesqtr  &lt;/CODE&gt;datasets is populating as expected. but when i use the same code outside Rsubmit the &lt;CODE class=" language-sas"&gt;datesqtr dataset is not populating as expected. Could you please suggest? &lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA _NULL_;
	YR_START_DATE=INTNX('MONTH', DATE(), -1, 'B');
	YR_END_DATE=INTNX('MONTH', YR_START_DATE, -12);

	DO UNTIL(YR_END_DATE&amp;gt;YR_START_DATE);
		i+1;
		MNTH_START_DATE=YR_START_DATE;
		MNTH_END_DATE=INTNX('MONTH', MNTH_START_DATE, 0, 'e');
		PREVDTE=INTNX('MONTH', MNTH_START_DATE, -1, 'S');

		/*PREVIOUS MONTHS DATE*/
		PUT MNTH_START_DATE=YYMMDD10. MNTH_END_DATE=YYMMDD10.  PREVDTE=YYMMDD10.;
		CALL SYMPUT(CATS('MNTH', I), PUT(MNTH_START_DATE, YYMMN6.));
		CALL SYMPUT(CATS('MNTHSTDT', I), PUT(MNTH_START_DATE, YYMMN6.));

		/*start date current month i.e. reporting period month t-1 month*/
		CALL SYMPUT(CATS('MNTHENDDT', I), PUT(MNTH_END_DATE, YYMMN6.));

		/*end date current month i.e. reporting period month t-1 month*/
		/*FIRST MONTHS DATE YYMM AS TRANSACTION DATE*/
		CALL SYMPUT(CATS('ATMDATE', I), PUT(PREVDTE, YYMMN6.));

		/*atm transaction for the reporting month month*/
		/*PREVIOUS MONTH DATE YYMM AS TRANSACTION DATE*/
		CALL SYMPUT(CATS('PREVDTE', I), PUT(INTNX('MONTH', MNTH_START_DATE, -1, 'S'), 
			YYMMDD10.));

		/*previous month date*/
		CALL SYMPUT(CATS('BGNDTE', I), PUT(INTNX('MONTH', MNTH_START_DATE, -3, 'S'), 
			YYMMDD10.));

		/*match to fetch the qtrly start date from the source format*/
		CALL SYMPUT(CATS('ENDDTE', I), PUT(INTNX('MONTH', MNTH_START_DATE, -2, 'E'), 
			YYMMDD10.));

		/*match to fetch the end qtrly date from the source format*/
		CALL SYMPUT(CATS('DATE', I), PUT(MNTH_START_DATE, YYMMN6.));

		/*transaction for previous months*/
		CALL SYMPUT(CATS('ATMDATE', I), PUT(PREVDTE, YYMMN6.));

		/*atm transaction for previous months*/
		/*PREVIOUS MONTH DATE YYMMDD AS TRANSACTION DATE*/
		YR_START_DATE=INTNX('MONTH', YR_START_DATE, -1);
	END;
	PUT YR_START_DATE YR_END_DATE;
RUN;

%macro test;
	%do i=1 %to 4;
		%let stdte&amp;amp;i. = %sysfunc(intnx(month, %sysfunc(today()), -&amp;amp;i.), 6.);
		%put stdte&amp;amp;i. = &amp;amp;&amp;amp;stdte&amp;amp;i.;
		%let endte&amp;amp;i. =  %eval(%sysfunc(intnx(month, &amp;amp;&amp;amp;stdte&amp;amp;i., 3), 6.)-1);
		%put endte&amp;amp;i. = &amp;amp;&amp;amp;endte&amp;amp;i.;

		proc sql;
			connect to teradata (user="&amp;amp;myname.@xxxx" 
				pass=&amp;amp;mypwd. tdpid=&amp;amp;id. mode=teradata);
			create table datesqtr as select * from connection to teradata
(select date_key, cldte_sas from xxxx.ss_dte_dim where cldte_sas 
				between &amp;amp;&amp;amp;stdte&amp;amp;i. - 4 and &amp;amp;&amp;amp;endte&amp;amp;i.
order by cldte_sas;
			) order by cldte_sas;
			disconnect from teradata;
		quit;

	%end;
%mend;

%test;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 18:36:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838692#M331608</guid>
      <dc:creator>Santt0sh</dc:creator>
      <dc:date>2022-10-14T18:36:32Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a table from Teradata using SAS macros.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838694#M331609</link>
      <description>&lt;P&gt;How does RSUBMIT have anything to do with this?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What are you rsubmitting?&lt;/P&gt;
&lt;P&gt;Where are you rsubmitting it from?&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Where are you rsubmitting it to?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to get a range of dates in Teradata use the built in CALENDER.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.teradata.com/r/Teradata-VantageTM-Data-Dictionary/March-2019/Data-Dictionary-Views/Using-System-Views/System-Calendar-View/Example-Using-Sys_Calendar.Calendar" target="_blank"&gt;https://docs.teradata.com/r/Teradata-VantageTM-Data-Dictionary/March-2019/Data-Dictionary-Views/Using-System-Views/System-Calendar-View/Example-Using-Sys_Calendar.Calendar&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 18:43:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838694#M331609</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-10-14T18:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a table from Teradata using SAS macros.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838696#M331611</link>
      <description>Hi Tom,&lt;BR /&gt;&lt;BR /&gt;Thank you for your quick response.&lt;BR /&gt;I am not sure what's going wrong when i run the code outside rsubmit.&lt;BR /&gt;1. What are you rsubmitting?&lt;BR /&gt;     Rsubmit;&lt;BR /&gt;%macro test;&lt;BR /&gt;Above Code...&lt;BR /&gt;&lt;BR /&gt;%mend;&lt;BR /&gt;%test;&lt;BR /&gt;Endrsubmit;&lt;BR /&gt;The sas code shared works when executted using Rsubmit, and doest work when i tried out side the Rsubmit.&lt;BR /&gt;&lt;BR /&gt;I will try to use the link provided Tom.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Oct 2022 18:49:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838696#M331611</guid>
      <dc:creator>Santt0sh</dc:creator>
      <dc:date>2022-10-14T18:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a table from Teradata using SAS macros.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838697#M331612</link>
      <description>&lt;P&gt;What is the SAS code you are trying to generate?&lt;/P&gt;
&lt;P&gt;What does this code do?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table datesqtr as
    select * from connection to teradata
(select date_key
      , cldte_sas
 from xxxx.ss_dte_dim
  where cldte_sas between &amp;amp;STDTE1 - 4 and &amp;amp;ENDTE1 
  order by cldte_sas
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What type of values does CLDTE_SAS contain?&lt;/P&gt;
&lt;P&gt;What type of values do the macro variables STDTE1 and ENDTE1 contain?&lt;/P&gt;
&lt;P&gt;Why are you also creating STDTE2, STDTE3 and STDTE4?&amp;nbsp; That is just making your macro code more complicated without any added value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 19:02:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838697#M331612</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-10-14T19:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a table from Teradata using SAS macros.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838698#M331613</link>
      <description>&lt;P&gt;If you don't also rsubmit the rest of the code where it the macro going to get the macro variables?&lt;/P&gt;
&lt;P&gt;Why just RSUBMIT the query instead?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test;
Rsubmit;
proc sql....

endrsubmit;
%mend;
%test;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Oct 2022 19:05:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838698#M331613</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-10-14T19:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a table from Teradata using SAS macros.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838700#M331614</link>
      <description>Post the log from the code. RSUBMIT sends the code to a server. Most likely you do not have access to the teradata server locally but the server does have access is my first guess.&lt;BR /&gt;&lt;BR /&gt;You need to run all the code either locally or on the server, you cannot do some locally and some on the server.</description>
      <pubDate>Fri, 14 Oct 2022 19:12:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838700#M331614</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-10-14T19:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a table from Teradata using SAS macros.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838703#M331616</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;CLDTE_SAS contains =  22,732&lt;BR /&gt;                                        22733 and so on. (SAS Date)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;SAS LOGS Run local not Rsubmit;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt; 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;BR /&gt; 68         &lt;BR /&gt; 69         DATA _NULL_;&lt;BR /&gt; 70         YR_START_DATE=INTNX('MONTH', DATE(), -1, 'B');&lt;BR /&gt; 71         YR_END_DATE=INTNX('MONTH', YR_START_DATE, -12);&lt;BR /&gt; 72         &lt;BR /&gt; 73         DO UNTIL(YR_END_DATE&amp;gt;YR_START_DATE);&lt;BR /&gt; 74         i+1;&lt;BR /&gt; 75         MNTH_START_DATE=YR_START_DATE;&lt;BR /&gt; 76         MNTH_END_DATE=INTNX('MONTH', MNTH_START_DATE, 0, 'e');&lt;BR /&gt; 77         PREVDTE=INTNX('MONTH', MNTH_START_DATE, -1, 'S');&lt;BR /&gt; 78         &lt;BR /&gt; 79         /*PREVIOUS MONTHS DATE*/&lt;BR /&gt; 80         PUT MNTH_START_DATE=YYMMDD10. MNTH_END_DATE=YYMMDD10.  PREVDTE=YYMMDD10.;&lt;BR /&gt; 81         CALL SYMPUT(CATS('MNTH', I), PUT(MNTH_START_DATE, YYMMN6.));&lt;BR /&gt; 82         CALL SYMPUT(CATS('MNTHSTDT', I), PUT(MNTH_START_DATE, YYMMN6.));&lt;BR /&gt; 83         &lt;BR /&gt; 84         /*start date current month i.e. reporting period month t-1 month*/&lt;BR /&gt; 85         CALL SYMPUT(CATS('MNTHENDDT', I), PUT(MNTH_END_DATE, YYMMN6.));&lt;BR /&gt; 86         &lt;BR /&gt; 87         /*end date current month i.e. reporting period month t-1 month*/&lt;BR /&gt; 88         /*FIRST MONTHS DATE YYMM AS TRANSACTION DATE*/&lt;BR /&gt; 89         CALL SYMPUT(CATS('ATMDATE', I), PUT(PREVDTE, YYMMN6.));&lt;BR /&gt; 90         &lt;BR /&gt; 91         /*atm transaction for the reporting month month*/&lt;BR /&gt; 92         /*PREVIOUS MONTH DATE YYMM AS TRANSACTION DATE*/&lt;BR /&gt; 93         CALL SYMPUT(CATS('PREVDTE', I), PUT(INTNX('MONTH', MNTH_START_DATE, -1, 'S'),&lt;BR /&gt; 94         YYMMDD10.));&lt;BR /&gt; 95         &lt;BR /&gt; 96         /*previous month date*/&lt;BR /&gt; 97         CALL SYMPUT(CATS('BGNDTE', I), PUT(INTNX('MONTH', MNTH_START_DATE, -3, 'S'),&lt;BR /&gt; 98         YYMMDD10.));&lt;BR /&gt; 99         &lt;BR /&gt; 100        /*match to fetch the qtrly start date from the source format*/&lt;BR /&gt; 101        CALL SYMPUT(CATS('ENDDTE', I), PUT(INTNX('MONTH', MNTH_START_DATE, -2, 'E'),&lt;BR /&gt; 102        YYMMDD10.));&lt;BR /&gt; 103        &lt;BR /&gt; 104        /*match to fetch the end qtrly date from the source format*/&lt;BR /&gt; 105        CALL SYMPUT(CATS('DATE', I), PUT(MNTH_START_DATE, YYMMN6.));&lt;BR /&gt; 106        &lt;BR /&gt; 107        /*transaction for previous months*/&lt;BR /&gt; 108        CALL SYMPUT(CATS('ATMDATE', I), PUT(PREVDTE, YYMMN6.));&lt;BR /&gt; 109        &lt;BR /&gt; 110        /*atm transaction for previous months*/&lt;BR /&gt; 111        /*PREVIOUS MONTH DATE YYMMDD AS TRANSACTION DATE*/&lt;BR /&gt; 112        YR_START_DATE=INTNX('MONTH', YR_START_DATE, -1);&lt;BR /&gt; 113        END;&lt;BR /&gt; 114        PUT YR_START_DATE YR_END_DATE;&lt;BR /&gt; 115        RUN;&lt;BR /&gt; &lt;BR /&gt; MNTH_START_DATE=2022-09-01 MNTH_END_DATE=2022-09-30 PREVDTE=2022-08-01&lt;BR /&gt; MNTH_START_DATE=2022-08-01 MNTH_END_DATE=2022-08-31 PREVDTE=2022-07-01&lt;BR /&gt; MNTH_START_DATE=2022-07-01 MNTH_END_DATE=2022-07-31 PREVDTE=2022-06-01&lt;BR /&gt; MNTH_START_DATE=2022-06-01 MNTH_END_DATE=2022-06-30 PREVDTE=2022-05-01&lt;BR /&gt; MNTH_START_DATE=2022-05-01 MNTH_END_DATE=2022-05-31 PREVDTE=2022-04-01&lt;BR /&gt; MNTH_START_DATE=2022-04-01 MNTH_END_DATE=2022-04-30 PREVDTE=2022-03-01&lt;BR /&gt; MNTH_START_DATE=2022-03-01 MNTH_END_DATE=2022-03-31 PREVDTE=2022-02-01&lt;BR /&gt; MNTH_START_DATE=2022-02-01 MNTH_END_DATE=2022-02-28 PREVDTE=2022-01-01&lt;BR /&gt; MNTH_START_DATE=2022-01-01 MNTH_END_DATE=2022-01-31 PREVDTE=2021-12-01&lt;BR /&gt; MNTH_START_DATE=2021-12-01 MNTH_END_DATE=2021-12-31 PREVDTE=2021-11-01&lt;BR /&gt; MNTH_START_DATE=2021-11-01 MNTH_END_DATE=2021-11-30 PREVDTE=2021-10-01&lt;BR /&gt; MNTH_START_DATE=2021-10-01 MNTH_END_DATE=2021-10-31 PREVDTE=2021-09-01&lt;BR /&gt; MNTH_START_DATE=2021-09-01 MNTH_END_DATE=2021-09-30 PREVDTE=2021-08-01&lt;BR /&gt; 22493 22524&lt;BR /&gt; NOTE: DATA statement used (Total process time):&lt;BR /&gt;       real time           0.00 seconds&lt;BR /&gt;       user cpu time       0.00 seconds&lt;BR /&gt;       system cpu time     0.00 seconds&lt;BR /&gt;       memory              647.03k&lt;BR /&gt;       OS Memory           23972.00k&lt;BR /&gt;       Timestamp           10/14/2022 07:17:46 PM&lt;BR /&gt;       Step Count                        24  Switch Count  0&lt;BR /&gt;       Page Faults                       0&lt;BR /&gt;       Page Reclaims                     238&lt;BR /&gt;       Page Swaps                        0&lt;BR /&gt;       Voluntary Context Switches        0&lt;BR /&gt;       Involuntary Context Switches      0&lt;BR /&gt;       Block Input Operations            0&lt;BR /&gt;       Block Output Operations           8&lt;BR /&gt;       &lt;BR /&gt; &lt;BR /&gt; 116        &lt;BR /&gt; 117        %macro test;&lt;BR /&gt; 118        %do i=1 %to 4;&lt;BR /&gt; 119        %let stdte&amp;amp;i. = %sysfunc(intnx(month, %sysfunc(today()), -&amp;amp;i.), 6.);&lt;BR /&gt; 120        %put stdte&amp;amp;i. = &amp;amp;&amp;amp;stdte&amp;amp;i.;&lt;BR /&gt; 121        %let endte&amp;amp;i. =  %eval(%sysfunc(intnx(month, &amp;amp;&amp;amp;stdte&amp;amp;i., 3), 6.)-1);&lt;BR /&gt; 122        %put endte&amp;amp;i. = &amp;amp;&amp;amp;endte&amp;amp;i.;&lt;BR /&gt; 123        &lt;BR /&gt; 124        /* proc sql; */&lt;BR /&gt; 125        /* connect to teradata (user="&amp;amp;myname.@xxxx"  */&lt;BR /&gt; 126        /* pass=&amp;amp;mypwd. tdpid=&amp;amp;id. mode=teradata); */&lt;BR /&gt; 127        /* create table datesqtr as select * from connection to teradata */&lt;BR /&gt; 128        /* (select date_key, cldte_sas from xxxx.ss_dte_dim where cldte_sas  */&lt;BR /&gt; 129        /* between &amp;amp;&amp;amp;stdte&amp;amp;i. - 4 and &amp;amp;&amp;amp;endte&amp;amp;i. */&lt;BR /&gt; 130        /* order by cldte_sas; */&lt;BR /&gt; 131        /* ) order by cldte_sas; */&lt;BR /&gt; 132        /* disconnect from teradata; */&lt;BR /&gt; 133        /* quit; */&lt;BR /&gt; 134        &lt;BR /&gt; 135        %end;&lt;BR /&gt; 136        %mend;&lt;BR /&gt; 137        &lt;BR /&gt; 138        %test;&lt;BR /&gt; stdte1 = 22889&lt;BR /&gt; endte1 = 22979&lt;BR /&gt; stdte2 = 22858&lt;BR /&gt; endte2 = 22949&lt;BR /&gt; stdte3 = 22827&lt;BR /&gt; endte3 = 22918&lt;BR /&gt; stdte4 = 22797&lt;BR /&gt; endte4 = 22888&lt;BR /&gt; 139        &lt;BR /&gt; 140        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;BR /&gt; 150        &lt;BR /&gt;</description>
      <pubDate>Fri, 14 Oct 2022 19:19:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838703#M331616</guid>
      <dc:creator>Santt0sh</dc:creator>
      <dc:date>2022-10-14T19:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a table from Teradata using SAS macros.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838706#M331618</link>
      <description>Hi Reeza,&lt;BR /&gt;&lt;BR /&gt;Thank you for your quick response!&lt;BR /&gt;Unfortunately, I can't post the Rsubmit logs, Apologies.&lt;BR /&gt;I have access to Teradata when I try running previously used code where the values are hardcoded for a period every 3 months in the Code i am able to create the required datasets, on my local.&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Oct 2022 19:25:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838706#M331618</guid>
      <dc:creator>Santt0sh</dc:creator>
      <dc:date>2022-10-14T19:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a table from Teradata using SAS macros.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838708#M331620</link>
      <description>If you can't post the logs, makes sure to set the macro debugging options on and run it in each set up and compare the two logs to see where they're different. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Oct 2022 19:28:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838708#M331620</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-10-14T19:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a table from Teradata using SAS macros.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838709#M331621</link>
      <description>Hi Reeza,&lt;BR /&gt;&lt;BR /&gt;That's was what I am trying to do.&lt;BR /&gt;&lt;BR /&gt;Thank you and I will keep posted</description>
      <pubDate>Fri, 14 Oct 2022 19:30:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838709#M331621</guid>
      <dc:creator>Santt0sh</dc:creator>
      <dc:date>2022-10-14T19:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a table from Teradata using SAS macros.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838714#M331624</link>
      <description>&lt;P&gt;Why would you store the SAS's internal representation of a date as a numeric field in Teradata?&lt;/P&gt;
&lt;P&gt;Why no make the variable a DATE field in Teradata?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am still not clear what the purpose of the Teradata query is.&amp;nbsp; Especially why you run it 4 different times.&lt;/P&gt;
&lt;P&gt;Why run it four different times and overwrite the same output dataset each time?&lt;BR /&gt;Why not just skip the first three runs since you are throwing them away?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 20:06:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838714#M331624</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-10-14T20:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a table from Teradata using SAS macros.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838804#M331658</link>
      <description>&lt;P&gt;Your macro test as posted doesn't really work as you describe it does. How much did you change your real code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test;
  %do i=1 %to 4;
    %let stdte&amp;amp;i. = %sysfunc(intnx(month, %sysfunc(today()), -&amp;amp;i.), 6.);
    %let endte&amp;amp;i. =  %eval(%sysfunc(intnx(month, &amp;amp;&amp;amp;stdte&amp;amp;i., 3), 6.)-1);
    %put stdte&amp;amp;i. = %sysfunc(putn(&amp;amp;&amp;amp;stdte&amp;amp;i.,date9.)) endte&amp;amp;i. = %sysfunc(putn(&amp;amp;&amp;amp;endte&amp;amp;i.,date9.));

    /**
    proc sql;
      connect to teradata (user="&amp;amp;myname.@xxxx" pass=&amp;amp;mypwd. tdpid=&amp;amp;id. mode=teradata);
      create table datesqtr as 
        select * 
          from connection to teradata
          (
            select date_key, cldte_sas 
            from xxxx.ss_dte_dim 
            where cldte_sas between &amp;amp;&amp;amp;stdte&amp;amp;i. - 4 and &amp;amp;&amp;amp;endte&amp;amp;i.
            ;
          ) 
          order by cldte_sas;
      disconnect from teradata;
    quit;
    **/

  %end;
%mend;

%test;&lt;/CODE&gt;&lt;/PRE&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;STRONG&gt;Issues in above macro logic&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1.&lt;/STRONG&gt; The time periods are overlapping&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_1-1665833277736.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76225iF29D428A5F2653DC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_1-1665833277736.png" alt="Patrick_1-1665833277736.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2.&lt;/STRONG&gt; The target table name is a fix string and though gets overwritten (re-created) by every single iteration of the loop. You need to use a dynamic table name instead like datesqtr_&amp;amp;i.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_2-1665833398023.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76226iCE4F8ADE8E9ED459/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_2-1665833398023.png" alt="Patrick_2-1665833398023.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;3.&lt;/STRONG&gt;&amp;nbsp;In the posted code there is an order by on the Teradata side and on the SAS side. Don't sort twice - that's just inefficient. Sort on the SAS side so the SAS table created gets the sort attribute set.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1665833887284.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76228i5ECC70B69CF619EF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1665833887284.png" alt="Patrick_0-1665833887284.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;4.&lt;/STRONG&gt; If this where clause works then "someone" must have stored SAS Date values in Teradata just as numbers instead of actual dates. This can work but.... why would one do that and loose all the date information and related functionality?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_3-1665833642985.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76227i47D1C051454AB451/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_3-1665833642985.png" alt="Patrick_3-1665833642985.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And last but not least the rsubmit story&lt;/P&gt;
&lt;P&gt;One reason why one would use rsubmit is: You have a locally installed SAS where you don't have access to Teradata, you have a remote SAS Server that has access to Teradata and you want to run your SAS script from the locally installed SAS. In such a case you would create a remote session via rsubmit where you run your code BUT if you then want to use the table in your local SAS session you need to either download the table or use remote library services.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would also expect that in such a scenario there are some additional part to rsubmit that you haven't shared - rsubmit &amp;lt;and here more stuff&amp;gt;; ...and a signon statement? etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Oct 2022 11:54:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/838804#M331658</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-10-15T11:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a table from Teradata using SAS macros.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/839193#M331820</link>
      <description>Hi Patrick,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thank you for your quick response!!&lt;BR /&gt;I will modify my code and follow the above.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Santosh&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 18 Oct 2022 13:42:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-from-Teradata-using-SAS-macros/m-p/839193#M331820</guid>
      <dc:creator>Santt0sh</dc:creator>
      <dc:date>2022-10-18T13:42:16Z</dc:date>
    </item>
  </channel>
</rss>

