<?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 Creation of data sets with macros, loops in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210887#M39077</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So here's the mission:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to create a series of data sets by merging tables in a proc sql procedure.&amp;nbsp; These tables are to be created by quarter, from Q1 2000 through Q1 2015, which means that in the end we'll have 61 separate data sets.&amp;nbsp; Doing this manually is far too time consuming, so I'd like to automate it.&amp;nbsp; I think that this ought to be possible with a combination of loops and macros.&amp;nbsp; I am competent enough with the former.&amp;nbsp; I am utterly worthless with regards to the latter, and this seems like a rough but doable learning opportunity.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My thinking is that I'm going to need two separate macro programs: one to repeat the proc sequel for each data set (while switching the date values when determining which data to grab), and another to generate macro variables to populate said date values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First, the procedure to be repeated:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql; &lt;BR /&gt; connect to oracle (user=&amp;amp;user. pass=&amp;amp;pass.);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; create table sastemp.["table"||&amp;amp;vsn]&lt;BR /&gt;&amp;nbsp;&amp;nbsp; as select *&lt;BR /&gt;&amp;nbsp;&amp;nbsp; from connection to oracle (&lt;BR /&gt;&amp;nbsp; select&amp;nbsp; a.variables,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; b.variables&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; from statictable1 b&lt;BR /&gt;&amp;nbsp;&amp;nbsp; left join statictable2 a on b.variable = a.variable&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; where b.datevariable between [&amp;amp;&amp;amp;startdt&amp;amp;i] and [&amp;amp;&amp;amp;enddt&amp;amp;i]&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt; ) order by variable ; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; disconnect from oracle ; &lt;BR /&gt;quit ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have run this successfully in SAS and have created the first dataset.&amp;nbsp; You'll note that three things need to change with each iteration of the proposed loop: [table||&amp;amp;vsn], which should be iteratively numbered with each pass; and [&amp;amp;startdt] and [&amp;amp;enddt], which should represent the first and last days of the quarter under examination, in SQL date format ('01-JAN-2000', for example).&amp;nbsp; This is where I imagine the second macro would come in.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm imagining creating a data set with three variables: vsn, start_date, and end_date.&amp;nbsp; [&amp;amp;vsn] would simply be an integer from 1 to 61, representing each iteration of the loop and providing a unique name to each table.&amp;nbsp; [&amp;amp;startdt] represents the first day of a quarter, and as you might expect, [&amp;amp;enddt] represents the last.&amp;nbsp; I have attempted to put together some (untested) code for creating this data set, but I'm not entirely sure how to manage the macro aspect of it, and could use some criticism/suggestions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do i = 1 to 61 ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; retain vsn 1 yearinteger 2000 ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if mod(i,4) = 1 then do ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("startdt"||strip(vsn),"'01-JAN-"||&amp;amp;yearinteger||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("enddt"||strip(vsn),"'31-MAR-"||&amp;amp;yearinteger||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; elseif mod(i,4) = 2 then do ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("startdt"||strip(vsn),"'01-APR-"||&amp;amp;yearinteger||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("enddt"||strip(vsn),"'30-JUN-"||&amp;amp;yearinteger||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; elseif mod(i,4) = 3 then do ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("startdt"||strip(vsn),"'01-JUL-"||&amp;amp;yearinteger||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("enddt"||strip(vsn),"'30-SEP-"||&amp;amp;yearinteger||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; else do ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("startdt"||strip(vsn),"'01-OCT-"||&amp;amp;yearinteger||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("enddt"||strip(vsn),"'31-DEC-"||&amp;amp;yearinteger||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;yearinteger = &amp;amp;yearinteger + 1 ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;amp;vsn = &amp;amp;vsn + 1 ;&lt;BR /&gt;end ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Surely this is filled with grievous errors, and for that I apologize.&amp;nbsp; I hope that this gives you a general idea of what I'm trying to do, and I would be extremely grateful for any advice from a more experienced programmer.&amp;nbsp; I've been banging my head against this for hours, but generally fail to grasp the intricacies of macros.&amp;nbsp; Thank you in advance for your help, kind person(s).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 24 Jul 2015 19:55:57 GMT</pubDate>
    <dc:creator>Tacos_Tacos_Tacos</dc:creator>
    <dc:date>2015-07-24T19:55:57Z</dc:date>
    <item>
      <title>Creation of data sets with macros, loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210887#M39077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So here's the mission:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to create a series of data sets by merging tables in a proc sql procedure.&amp;nbsp; These tables are to be created by quarter, from Q1 2000 through Q1 2015, which means that in the end we'll have 61 separate data sets.&amp;nbsp; Doing this manually is far too time consuming, so I'd like to automate it.&amp;nbsp; I think that this ought to be possible with a combination of loops and macros.&amp;nbsp; I am competent enough with the former.&amp;nbsp; I am utterly worthless with regards to the latter, and this seems like a rough but doable learning opportunity.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My thinking is that I'm going to need two separate macro programs: one to repeat the proc sequel for each data set (while switching the date values when determining which data to grab), and another to generate macro variables to populate said date values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First, the procedure to be repeated:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql; &lt;BR /&gt; connect to oracle (user=&amp;amp;user. pass=&amp;amp;pass.);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; create table sastemp.["table"||&amp;amp;vsn]&lt;BR /&gt;&amp;nbsp;&amp;nbsp; as select *&lt;BR /&gt;&amp;nbsp;&amp;nbsp; from connection to oracle (&lt;BR /&gt;&amp;nbsp; select&amp;nbsp; a.variables,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; b.variables&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; from statictable1 b&lt;BR /&gt;&amp;nbsp;&amp;nbsp; left join statictable2 a on b.variable = a.variable&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; where b.datevariable between [&amp;amp;&amp;amp;startdt&amp;amp;i] and [&amp;amp;&amp;amp;enddt&amp;amp;i]&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt; ) order by variable ; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; disconnect from oracle ; &lt;BR /&gt;quit ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have run this successfully in SAS and have created the first dataset.&amp;nbsp; You'll note that three things need to change with each iteration of the proposed loop: [table||&amp;amp;vsn], which should be iteratively numbered with each pass; and [&amp;amp;startdt] and [&amp;amp;enddt], which should represent the first and last days of the quarter under examination, in SQL date format ('01-JAN-2000', for example).&amp;nbsp; This is where I imagine the second macro would come in.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm imagining creating a data set with three variables: vsn, start_date, and end_date.&amp;nbsp; [&amp;amp;vsn] would simply be an integer from 1 to 61, representing each iteration of the loop and providing a unique name to each table.&amp;nbsp; [&amp;amp;startdt] represents the first day of a quarter, and as you might expect, [&amp;amp;enddt] represents the last.&amp;nbsp; I have attempted to put together some (untested) code for creating this data set, but I'm not entirely sure how to manage the macro aspect of it, and could use some criticism/suggestions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do i = 1 to 61 ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; retain vsn 1 yearinteger 2000 ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if mod(i,4) = 1 then do ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("startdt"||strip(vsn),"'01-JAN-"||&amp;amp;yearinteger||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("enddt"||strip(vsn),"'31-MAR-"||&amp;amp;yearinteger||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; elseif mod(i,4) = 2 then do ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("startdt"||strip(vsn),"'01-APR-"||&amp;amp;yearinteger||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("enddt"||strip(vsn),"'30-JUN-"||&amp;amp;yearinteger||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; elseif mod(i,4) = 3 then do ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("startdt"||strip(vsn),"'01-JUL-"||&amp;amp;yearinteger||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("enddt"||strip(vsn),"'30-SEP-"||&amp;amp;yearinteger||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; else do ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("startdt"||strip(vsn),"'01-OCT-"||&amp;amp;yearinteger||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("enddt"||strip(vsn),"'31-DEC-"||&amp;amp;yearinteger||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;yearinteger = &amp;amp;yearinteger + 1 ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;amp;vsn = &amp;amp;vsn + 1 ;&lt;BR /&gt;end ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Surely this is filled with grievous errors, and for that I apologize.&amp;nbsp; I hope that this gives you a general idea of what I'm trying to do, and I would be extremely grateful for any advice from a more experienced programmer.&amp;nbsp; I've been banging my head against this for hours, but generally fail to grasp the intricacies of macros.&amp;nbsp; Thank you in advance for your help, kind person(s).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jul 2015 19:55:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210887#M39077</guid>
      <dc:creator>Tacos_Tacos_Tacos</dc:creator>
      <dc:date>2015-07-24T19:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of data sets with macros, loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210888#M39078</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why separate into 61 datasets in the first place, why not do one big query?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jul 2015 20:22:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210888#M39078</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-07-24T20:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of data sets with macros, loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210889#M39079</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The amount of data is enormous.&amp;nbsp; One of the tables has in the realm of ~4 billion rows of data, so doing this all in a single query puts far too much strain on my server resources.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jul 2015 20:32:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210889#M39079</guid>
      <dc:creator>Tacos_Tacos_Tacos</dc:creator>
      <dc:date>2015-07-24T20:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of data sets with macros, loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210890#M39080</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok...&lt;/P&gt;&lt;P&gt;1. Create&amp;nbsp; macro to do the extract&lt;/P&gt;&lt;P&gt;2. Create list of dates/qrtrs for parameters&lt;/P&gt;&lt;P&gt;3. Execute using call execute (step2/3 could be one step).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think this will work, but you can debug on your side. In particular make sure the date is being passed to the server in a manner that it expects.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro extract(qrtr=, start=, end=);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql; &lt;/P&gt;&lt;P&gt;connect to oracle (user=&amp;amp;user. pass=&amp;amp;pass.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;create table sastemp.["table"||&amp;amp;qrtr]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; as select *&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; from connection to oracle (&lt;/P&gt;&lt;P&gt;&amp;nbsp; select&amp;nbsp; a.variables,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; b.variables&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; from statictable1 b&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; left join statictable2 a on b.variable = a.variable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; where b.datevariable between [&amp;amp;start] and [&amp;amp;end]&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;) order by variable ; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; disconnect from oracle ; &lt;/P&gt;&lt;P&gt;quit ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;length str $256.;&lt;/P&gt;&lt;P&gt;start_date='01Jan2000'd;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do qrtr=1 to 61;&lt;/P&gt;&lt;P&gt;end_date=intnx('MONTH', start_date, 3, 'b')-1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;str='%extract(qrtr='||put(qrtr, z3.)||', start='||put(start_date,date11.)||", end="||put(end_date, date11.)||');';&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start_date=end_date+1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;format start_date end_date date9.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;set want;&lt;/P&gt;&lt;P&gt;call execute(str);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jul 2015 21:26:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210890#M39080</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-07-24T21:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of data sets with macros, loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210891#M39081</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have a working macro to do this for ONE of your output data sets then create a SAS data set with the parameters that macro needs. Then you can use Call Execute to pass those parameters to the macro, creating all the remaining needed data sets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A control set can be made with:&lt;/P&gt;&lt;P&gt;data control;&lt;/P&gt;&lt;P&gt;yearinteger =2000;&lt;/P&gt;&lt;P&gt;do vsn = 1 to 61 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if mod(vsn,4) = 1 then do ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; startdt = cats("'01-JAN-",yearinteger,"'");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; enddt&amp;nbsp;&amp;nbsp; = cats("'31-MAR-",yearinteger,"'") ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else if mod(vsn,4) = 2 then do ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; startdt = cats("'01-APR-",yearinteger,"'");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; enddt&amp;nbsp;&amp;nbsp; = cats("'31-JUN-",yearinteger,"'") ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else if mod(vsn,4) = 3 then do ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; startdt = cats("'01-JUL-",yearinteger,"'");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; enddt&amp;nbsp;&amp;nbsp; = cats("'31-SEP-",yearinteger,"'") ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else do ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; startdt = cats("'01-OCT-",yearinteger,"'");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; enddt&amp;nbsp;&amp;nbsp; = cats("'31-DEC-",yearinteger,"'") ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yearinteger = yearinteger + 1 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;end ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;A separate dataset lets you verify that the parameters look the way that you want them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and use something like:&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set control;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute ('%yourmacroname( vsn=' || vsn || ', startdt=' || startdt || ', enddt=' || enddt || ')' );&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;of course the macro call has to match how you define the macro.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jul 2015 21:33:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210891#M39081</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-07-24T21:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of data sets with macros, loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210892#M39082</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many parameters in play here, but there may be a better way.&lt;/P&gt;&lt;P&gt;Creating new tables still strains the server. Do you really want to duplicate all 4 billions records?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the source was SAS, much better to point to the original table with where clauses (if table is sorted and sort-validated) or obs= lastobs= options. Since this is Oracle, you are a bit more constrained.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;What the first step of your process?&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;If you can't point to the original data (with a where clause) for this step, then create a view and process the view (provided this data is only read once). If you need the data sorted, better have Oracle sort it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;SPAN style="color: navy; background: none repeat scroll 0% 0% lime; font-family: 'Courier New';"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt; loopdates(startd=&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: none repeat scroll 0% 0% white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;199912&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;, endd=&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: none repeat scroll 0% 0% white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;199912&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%local&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt; daten &lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;date_yymm &lt;/SPAN&gt;daten_endq &lt;SPAN style="color: black; background: none repeat scroll 0% 0% white; font-family: 'Courier New';"&gt;date_ora1 &lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;date_ora2&lt;/SPAN&gt;&lt;/SPAN&gt;; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt; daten=&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;(inputn(&amp;amp;startd,yymmn6.));&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%do&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%while&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;(&amp;amp;daten&amp;lt;=&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;(inputn(&amp;amp;endd,&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: none repeat scroll 0% 0% white;"&gt;yymmn6.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;)));&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt; date_yymm =&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;(putn(&amp;amp;daten&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,yyq.)) ; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt; daten_endq=&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;(intnx(quarter,&amp;amp;daten,0,e));&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt; date_ora1 =&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;(%')&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;(putn(&amp;amp;daten&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,date9.))&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;(%');&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt; date_ora2 =&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;(%')&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;(putn(&amp;amp;daten_endq,date9.))&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;(%');&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; create view SASTEMP.TABLE_&amp;amp;date_yymm.&amp;nbsp; as&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where b.DATEVARIABLE between &amp;amp;date_ora1. and &amp;amp;date_ora2.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt; daten=&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;(intnx(quarter,&amp;amp;daten,1));&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;SPAN style="color: navy; background: none repeat scroll 0% 0% lime; font-family: 'Courier New';"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;%&lt;STRONG&gt;&lt;EM&gt;loopdates&lt;/EM&gt;&lt;/STRONG&gt;(startd=&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: none repeat scroll 0% 0% white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;200701&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;, endd=&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: none repeat scroll 0% 0% white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;201112&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;creates:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;... create view SASTEMP.TABLE2011Q4&amp;nbsp; as&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;where b.DATEVARIABLE between '01OCT2011' and '31DEC2011'&amp;nbsp;&amp;nbsp; ...&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But if you can put the actual processing logic in this macro rather than a view creation, it is even better.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Jul 2015 03:24:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210892#M39082</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2015-07-28T03:24:45Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of data sets with macros, loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210893#M39083</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're dealing with serious volumes here. Let's assume that you really need to replicate the data into SAS files. You say that "&lt;SPAN style="font-size: 13px; background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;EM&gt;so doing this all in a single query puts far too much strain on my server resources&lt;/EM&gt;&lt;/SPAN&gt;". I'd ask what happens if you execute your query 61 times and it probably results in full table scans in Oracle every single time? That would be much worse.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Depending on how you need to use your data in SAS creating 61 files makes eventually sense. Have you considered using the SPDE engine?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also: If your Oracle table really has 4 Billion rows and there is a date column (eg. for transactions), then there is a good chance that the Oracle table is partitioned. If so then it would be really important that you define your query "partition wise". This would make a huge difference.&lt;/P&gt;&lt;P&gt;Make sure you investigate how the actual Oracle DDL looks like and that you run an "Explain" to performance tweak your query. Once you're there then it shouldn't be too hard to set-up some SAS code (with or without macros) to get what you need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you can: Share the DDL of your Oracle tables (as attachments) and the exact logic with all the columns you need in SAS. Also let us know if your downstream processing will be month based (so multiple tables would make sense) or not (then rather go for the SPDE engine).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe to remember that the SPDE engine also allows for multi-threaded download of data from Oracle. So this is also something we should be looking into.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How long did it take you to create this one single month table (real time)? Is this time multiplied by 61 something acceptable or would we also need to think about running the extraction jobs in parallel? Do you have SAS/Connect licensed at your site?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Jul 2015 09:21:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210893#M39083</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-07-28T09:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of data sets with macros, loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210894#M39084</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mission accomplished.&amp;nbsp; Thank you to all who answered, not only for coding suggestions, but also for alternative ways of considering the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ultimately, I went with a form of ballardw's response - largely because it made the most immediate sense to me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro productloop ;&lt;/P&gt;&lt;P&gt;%let yearinteger = 2000 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %do vsn = 1 %to 61 ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data _null_;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if %sysfunc(mod(&amp;amp;vsn,4))= 1 %then %do ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("startdt", "'01-JAN-"||strip(&amp;amp;yearinteger.)||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("enddt", "'31-MAR-"||strip(&amp;amp;yearinteger.)||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let quarter = "Q1" ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let twodigityear = substrn(&amp;amp;yearinteger.,3,2) ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("mergeset", "&amp;lt;filepath&amp;gt;"||&amp;amp;twodigityear.||&amp;amp;quarter.) ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("g1filename", "&amp;lt;filepath&amp;gt;"||&amp;amp;twodigityear.||&amp;amp;quarter.||"G1") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("g2filename", "&amp;lt;filepath&amp;gt;"||&amp;amp;twodigityear.||&amp;amp;quarter.||"G2") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("g1output", "'&amp;lt;filepath&amp;gt;"||&amp;amp;twodigityear.||&amp;amp;quarter.||"G1.csv'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("g2output", "'&amp;lt;filepath&amp;gt;"||&amp;amp;twodigityear.||&amp;amp;quarter.||"G2.csv'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %datagen;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %else %if %sysfunc(mod(&amp;amp;vsn,4))= 2 %then %do ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("startdt", "'01-APR-"||strip(&amp;amp;yearinteger.)||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("enddt", "'30-JUN-"||strip(&amp;amp;yearinteger.)||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let quarter = "Q2" ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let twodigityear = substrn(&amp;amp;yearinteger.,3,2) ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("mergeset", "&amp;lt;filepath&amp;gt;"||&amp;amp;twodigityear.||&amp;amp;quarter.) ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("g1filename", "&amp;lt;filepath&amp;gt;"||&amp;amp;twodigityear.||&amp;amp;quarter.||"G1") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("g2filename", "&amp;lt;filepath&amp;gt;"||&amp;amp;twodigityear.||&amp;amp;quarter.||"G2") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("g1output", "'&amp;lt;filepath&amp;gt;"||&amp;amp;twodigityear.||&amp;amp;quarter.||"G1.csv'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("g2output", "'&amp;lt;filepath&amp;gt;"||&amp;amp;twodigityear.||&amp;amp;quarter.||"G2.csv'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %datagen;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %else %if %sysfunc(mod(&amp;amp;vsn,4))= 3 %then %do ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("startdt", "'01-JUL-"||strip(&amp;amp;yearinteger.)||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("enddt", "'30-SEP-"||strip(&amp;amp;yearinteger.)||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let quarter = "Q3" ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let twodigityear = substrn(&amp;amp;yearinteger.,3,2) ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("mergeset", "&amp;lt;filepath&amp;gt;"||&amp;amp;twodigityear.||&amp;amp;quarter.) ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("g1filename", "&amp;lt;filepath&amp;gt;"||&amp;amp;twodigityear.||&amp;amp;quarter.||"G1") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("g2filename", "&amp;lt;filepath&amp;gt;"||&amp;amp;twodigityear.||&amp;amp;quarter.||"G2") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("g1output", "'&amp;lt;filepath&amp;gt;"||&amp;amp;twodigityear.||&amp;amp;quarter.||"G1.csv'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("g2output", "'&amp;lt;filepath&amp;gt;"||&amp;amp;twodigityear.||&amp;amp;quarter.||"G2.csv'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %datagen;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %else %do ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("startdt", "'01-OCT-"||strip(&amp;amp;yearinteger.)||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("enddt", "'31-DEC-"||strip(&amp;amp;yearinteger.)||"'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let quarter = "Q4" ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let twodigityear = substrn(&amp;amp;yearinteger.,3,2) ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("mergeset", "&amp;lt;filepath&amp;gt;"||&amp;amp;twodigityear.||&amp;amp;quarter.) ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("g1filename", "&amp;lt;filepath&amp;gt;"||&amp;amp;twodigityear.||&amp;amp;quarter.||"G1") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("g2filename", "&amp;lt;filepath&amp;gt;"||&amp;amp;twodigityear.||&amp;amp;quarter.||"G2") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("g1output", "'&amp;lt;filepath&amp;gt;"||&amp;amp;twodigityear.||&amp;amp;quarter.||"G1.csv'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("g2output", "'&amp;lt;filepath&amp;gt;"||&amp;amp;twodigityear.||&amp;amp;quarter.||"G2.csv'") ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %datagen;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data _null_ ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let yearinteger = sum(&amp;amp;yearinteger., 1) ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; %end ;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%mend productloop ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the outer loop, within which I ran the "datagen" macro, which merged tables with proc sql and performed the various calculations I needed to do while using the myriad macro variables defined in said outer loop.&amp;nbsp; It is perhaps not the most elegant code, but what it lacks in beauty it makes up for in functionality.&amp;nbsp; A few notable hang-ups:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I did not know that the "call symput" function required a preceding "data _null_" declaration, creating a situation in which the first data set would be created without a problem, but subsequent iterations would error out without any explanation as to why within the log.&amp;nbsp; Fixed by placing a "data _null_" statement at the top of the loop.&lt;/LI&gt;&lt;LI&gt;The difference between "%let" and "call symput" remains somewhat elusive to me, though I had to switch between the two quite a bit before the resulting code behaved as desired.&lt;/LI&gt;&lt;LI&gt;Similarly, while the difference between "if" and "%if" is clear enough (I think), it's not immediately obvious to me why the macro versions of the other commands/functions (%to, %do, %end, etc.) were necessary, aside from the fact that the code wouldn't run otherwise.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, just wanted to give a final update and a hearty "thank you" for the assistance.&amp;nbsp; I've got quite a bit to learn yet, but this has taught me a substantial amount.&amp;nbsp; Cheers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2015 21:08:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210894#M39084</guid>
      <dc:creator>Tacos_Tacos_Tacos</dc:creator>
      <dc:date>2015-07-30T21:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of data sets with macros, loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210895#M39085</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Holy Molly! Please enrol to a macro course!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jul 2015 00:27:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210895#M39085</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2015-07-31T00:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of data sets with macros, loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210896#M39086</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;+1.&amp;nbsp; Sounds like a right mess.&amp;nbsp; I would suggest you go with Patrick's post.&amp;nbsp; Have a talk with the database experts and ask them to suggest some techniques to dump the database data into the block you need.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jul 2015 09:05:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210896#M39086</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-07-31T09:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of data sets with macros, loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210897#M39087</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are going to use a data step to generate the macro variables then why to you need all of the macro %IF statements?&lt;/P&gt;&lt;P&gt;Why not just do that within the data step using normal IF statements?&amp;nbsp; Normal SAS code is much easier to debug than macro code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or alternatively if all you are doing in the CALL SYMPUT is concatenating macro variable values then why do you need the CALL SYMPUT() functions at all?&lt;/P&gt;&lt;P&gt;For example consider the first CALL SYMPUT() function call.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt; line-height: 1.5em; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt; line-height: 1.5em; background-color: #ffffff;"&gt;call symput("startdt", "'01-JAN-"||strip(&amp;amp;yearinteger.)||"'") ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; line-height: 1.5em; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;That is the same as&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;%let STARTDT=%sysfunc(dequote("'01-JAN-&amp;amp;yearinteger'")) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also why are you setting the macro variable YEARINTEGER to have the code to call the SUM() function?&amp;nbsp; Why not just set it to have the number that would result if you actually did the addition?&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;Replace&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt; background-color: #ffffff;"&gt;%let yearinteger = sum(&amp;amp;yearinteger., 1) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;with &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt; background-color: #ffffff;"&gt;%let yearinteger = %eval(&amp;amp;yearinteger + 1) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jul 2015 10:19:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creation-of-data-sets-with-macros-loops/m-p/210897#M39087</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-07-31T10:19:38Z</dc:date>
    </item>
  </channel>
</rss>

