<?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: Append weekly data to create a to date Financial year dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Append-weekly-data-to-create-a-to-date-Financial-year-dataset/m-p/250790#M47312</link>
    <description>&lt;P&gt;Sorry, its not clear to me why you need that code to create various things and append, and then have it in a macro? &amp;nbsp;The SQL code which gets the data from the database can directly insert the data into the required dataset. &amp;nbsp;But then the question arises, why are you subsetting the data inserted, but don't appear to do anything with the subset, and then require a macro to keep doing it? &amp;nbsp;Just select all the data and insert it?&lt;/P&gt;
&lt;PRE&gt;proc sql;
  connect to teradata (&amp;amp;TDCON.);
  insert into SAVE.FYTD_REPORT
  select * from connection to teradata
  (
    select  *  
    from    EMP
    where   EXTRACT_DATE &amp;lt;= &amp;amp;TDDATE.
      and   DOE between &amp;amp;STARTDATE. and ENDDATE;
  );
  disconnect from teradata;
quit;&lt;/PRE&gt;
&lt;P&gt;Note, notice the use of {i} to post code as this keeps formatting. &amp;nbsp;Also note that easy to read code is far better to other people reading your code, note the consitent indentations, consistent capitilisation, finishing macvro variables with "." etc.&lt;/P&gt;</description>
    <pubDate>Thu, 18 Feb 2016 09:40:48 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-02-18T09:40:48Z</dc:date>
    <item>
      <title>Append weekly data to create a to date Financial year dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-weekly-data-to-create-a-to-date-Financial-year-dataset/m-p/250762#M47307</link>
      <description>&lt;P&gt;&lt;FONT size="2"&gt;Program is run every week for the previous Friday ( for example: 15/02/2016) a report should be run with end date as (12/02/2016). &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;So,&amp;nbsp;a week's start date is Saturday and End date is a&amp;nbsp;Friday. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;For running this a Autoexec is setup which gets the WKstart, EndDATE by providing something like this. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; trig_file=150619; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%INCLUDE&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New"&gt;&lt;FONT color="#800080" face="Courier New"&gt;&lt;FONT color="#800080" face="Courier New"&gt;"/sasdata/abc/environment/dev/autoexec.sas"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;This gets resolved and values such as are generated, which I use in my code.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;RUNDATE = 20160212&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;ENDDATE = &lt;FONT face="Courier New"&gt;20160212&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;STARTDATE = &lt;FONT face="Courier New"&gt;20160206&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;TDDate= 1&lt;FONT face="Courier New"&gt;160212&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;FinYear_start =&amp;nbsp;20150701&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;This is my example code :&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; trig_file=XX_150619; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%INCLUDE&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New"&gt;&lt;FONT color="#800080" face="Courier New"&gt;&lt;FONT color="#800080" face="Courier New"&gt;"/sasdata/abc/environment/dev/autoexec.sas"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;STRONG&gt;Proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New"&gt;Sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;connect&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; Teradata (&amp;amp;tdcon);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;Create&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;table&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; work.report&amp;amp;RUNDATE &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;Select&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; * &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;from&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; connection to teradata&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;(&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;Select&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; * &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;from&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; emp&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;where&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;extract_date &amp;lt;= &amp;amp;TdDATE&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;and&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; DOE &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;between&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; &amp;amp;StartDate &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;and&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; EndDate;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;) ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;disconnect&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;from&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; teradata;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;STRONG&gt;Proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New"&gt;append&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;Base&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;= Save.FYTD_report &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;= report&amp;amp;RUNDATE;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff6600" size="2"&gt;I want to embed this code into to a macro which can be run will from start&amp;nbsp; of financial year till last friday by providing &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff6600"&gt;%concat_report(&lt;FONT face="Courier New"&gt;XX_150703);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff6600" face="Courier New"&gt;%concat_report(&lt;FONT face="Courier New"&gt;XX_150710);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I do this ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried doing this but doesn't work&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; concat_report(rdate=);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%let&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; trig_file=&amp;amp;rdate; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%INCLUDE&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New"&gt;&lt;FONT color="#800080" face="Courier New"&gt;&lt;FONT color="#800080" face="Courier New"&gt;"/sasdata/abc/environment/dev/autoexec.sas"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;PROC SQL;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;blah blah&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;PROC APPEND blah ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; concat_report;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;%&lt;STRONG&gt;&lt;I&gt;concat_report&lt;/I&gt;&lt;/STRONG&gt;( XX_150619);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2016 05:32:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-weekly-data-to-create-a-to-date-Financial-year-dataset/m-p/250762#M47307</guid>
      <dc:creator>hammerman</dc:creator>
      <dc:date>2016-02-18T05:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Append weekly data to create a to date Financial year dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-weekly-data-to-create-a-to-date-Financial-year-dataset/m-p/250772#M47310</link>
      <description>&lt;P&gt;What happened (log?)&lt;/P&gt;
&lt;P&gt;For further diagnosis, we will need the exact code of the whole macro, as macro programming can (and will) be tricky.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your first example, trig_file is purely numeric, but then you use the XX_ prefix. Are you sure your auotexec.sas can deal with that correctly?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2016 07:17:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-weekly-data-to-create-a-to-date-Financial-year-dataset/m-p/250772#M47310</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-02-18T07:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: Append weekly data to create a to date Financial year dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-weekly-data-to-create-a-to-date-Financial-year-dataset/m-p/250790#M47312</link>
      <description>&lt;P&gt;Sorry, its not clear to me why you need that code to create various things and append, and then have it in a macro? &amp;nbsp;The SQL code which gets the data from the database can directly insert the data into the required dataset. &amp;nbsp;But then the question arises, why are you subsetting the data inserted, but don't appear to do anything with the subset, and then require a macro to keep doing it? &amp;nbsp;Just select all the data and insert it?&lt;/P&gt;
&lt;PRE&gt;proc sql;
  connect to teradata (&amp;amp;TDCON.);
  insert into SAVE.FYTD_REPORT
  select * from connection to teradata
  (
    select  *  
    from    EMP
    where   EXTRACT_DATE &amp;lt;= &amp;amp;TDDATE.
      and   DOE between &amp;amp;STARTDATE. and ENDDATE;
  );
  disconnect from teradata;
quit;&lt;/PRE&gt;
&lt;P&gt;Note, notice the use of {i} to post code as this keeps formatting. &amp;nbsp;Also note that easy to read code is far better to other people reading your code, note the consitent indentations, consistent capitilisation, finishing macvro variables with "." etc.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2016 09:40:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-weekly-data-to-create-a-to-date-Financial-year-dataset/m-p/250790#M47312</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-02-18T09:40:48Z</dc:date>
    </item>
  </channel>
</rss>

