<?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: Iteration loops to macros in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184724#M35051</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The call execute is putting sas codelines into the interpreter&amp;nbsp; that will be picked up after a processing boundary.&lt;/P&gt;&lt;P&gt;In this case AFTER the datastep his run, the new code picked up and it will see:&amp;nbsp;&amp;nbsp;&amp;nbsp; class ... "=student ".... '&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;Not really valid code as there is nothing else.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 24 Jul 2014 06:06:31 GMT</pubDate>
    <dc:creator>jakarman</dc:creator>
    <dc:date>2014-07-24T06:06:31Z</dc:date>
    <item>
      <title>Iteration loops to macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184716#M35043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am now writing a SQL to create an &lt;SPAN style="text-decoration: underline;"&gt;empty dataset&lt;/SPAN&gt; with structured variable names for my school record as below.&amp;nbsp; Is it possible for me to use macros with iteration loops for the PROC SQL ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g. variable names : student_id, boy_000-boy_300, girl_000-girl_300 and school_total&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp; create table student&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (student_id&amp;nbsp;&amp;nbsp;&amp;nbsp; char(3),&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; boy_000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num format F3.,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; boy_001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num format F3.,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..........................................&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; boy_299&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num format F3.,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; boy_300&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num format F3.,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; girl_000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num format F3.,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; girl_001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num format F3.,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..........................................&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; girl_299&amp;nbsp;&amp;nbsp;&amp;nbsp; num format F3.,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; girl_300&amp;nbsp;&amp;nbsp;&amp;nbsp; num format F3.,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; school_total&amp;nbsp; num format F5.);&lt;BR /&gt;quit;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;may&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jul 2014 03:51:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184716#M35043</guid>
      <dc:creator>wongmay</dc:creator>
      <dc:date>2014-07-18T03:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration loops to macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184717#M35044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why use SQL to create a table?&amp;nbsp; Much easier to use a data step where you will have full access to the SAS syntax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; student ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; student_id $&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; boy_000-boy_300 girl_000-girl_300 school_total &lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;8&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; boy: girl: &lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;3.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; school_total 5&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;stop&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jul 2014 04:15:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184717#M35044</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-07-18T04:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration loops to macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184718#M35045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great help !&amp;nbsp; Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;may&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jul 2014 07:43:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184718#M35045</guid>
      <dc:creator>wongmay</dc:creator>
      <dc:date>2014-07-18T07:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration loops to macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184719#M35046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could also generate the required syntax from a loop, see below.&amp;nbsp; It depends on scenario really.&amp;nbsp; IMO Tom's suggestion of the datastep is not really a huge saving.&amp;nbsp; You still need to specify each variable, ok you can save typing num format=f3., but then that is what cut and paste is for.&amp;nbsp; So its mainly style preference.&amp;nbsp; I tend to favour SQL with each variable on a row so you can modify each individually quite straightforwardly.&amp;nbsp; Where I find it harder to read a long string across the page and add extra, but that may just be me.&amp;nbsp; One other consideration is if you are running code on multiple systems, e.g. if your using Toad and testing pass through code, switching to datastep wouldn't work then.&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;&amp;nbsp; call execute('proc sql; create table STUDENT (student_id char(3)');&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i="boy_000","boy_001","boy_299";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute(','||i||' num format f3.');&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; call execute(');quit;');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jul 2014 08:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184719#M35046</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-07-18T08:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration loops to macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184720#M35047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you RW9.&amp;nbsp; I have modified the syntax below and it worked successfully.&amp;nbsp; Both DATA STEP and PROC SQL are quite useful and help me so much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*******************************************************************************************************&lt;/P&gt;&lt;P&gt;%symdel x;&lt;BR /&gt;%let tot_std=100;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _NULL_;&lt;BR /&gt;&amp;nbsp; call execute('proc sql; create table output.tt (student_id char(3)');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=1 to &amp;amp;tot_std;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("x",put(i,z3.));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute(",boy_&amp;amp;x&amp;nbsp; num format f3.");&lt;BR /&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=1 to &amp;amp;tot_std;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("x",put(i,z3.));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute(",girl_&amp;amp;x&amp;nbsp; num format f3.");&lt;BR /&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; call execute(",student_total&amp;nbsp; num format f3.");&lt;BR /&gt;&amp;nbsp; call execute(");quit;");&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;*******************************************************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;may&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jul 2014 01:04:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184720#M35047</guid>
      <dc:creator>wongmay</dc:creator>
      <dc:date>2014-07-21T01:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration loops to macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184721#M35048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would be very careful about using symput with call execute.&amp;nbsp; There is a feature of call execute which will resolve macros at the time call execute is called, not afterwards.&amp;nbsp; It may not affect here, but you will have times where code runs fine, but you only get one resolution to macros.&amp;nbsp; I would re-write your code to avoid the use of macro variables, so instead of the call symputs and &amp;amp;'s, just (strip as using best) put the number to text.&amp;nbsp; If you need tot_std as a macro variable, then you still can and set the variable in the datastep to that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _NULL_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tot_std=100;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('proc sql; create table output.tt (student_id char(3)');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to tot_std;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute(",boy_"||strip(put(I,best.))||"&amp;nbsp; num format f3.");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to &amp;amp;tot_std;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute(",girl_"||strip(put(I,best.))||"&amp;nbsp; num format f3.");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute(",student_total&amp;nbsp; num format f3.); quit;");&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jul 2014 08:26:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184721#M35048</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-07-21T08:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration loops to macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184722#M35049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Work fine ! Thank you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;may&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jul 2014 23:35:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184722#M35049</guid>
      <dc:creator>wongmay</dc:creator>
      <dc:date>2014-07-21T23:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration loops to macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184723#M35050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, RW9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I am quite interesting in using "call execute()" to simplify most procedure steps based on the above example.&amp;nbsp; I review from the website that "call execute(argument)" is necessary.&amp;nbsp; When I try to write the following step, a message "Statement is not valid or it is used out of proper order." listed in log.&amp;nbsp; Please let me learn how to write "call execute()" to tackle my silly problem:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g. I want to set class1=student1,.......class10=student10,&lt;/P&gt;&lt;P&gt;data dummy;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set examine;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do m=1 to 10;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute("class" || m || "=student" || m || ";");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;jones&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 05:35:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184723#M35050</guid>
      <dc:creator>JonesSmith</dc:creator>
      <dc:date>2014-07-24T05:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration loops to macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184724#M35051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The call execute is putting sas codelines into the interpreter&amp;nbsp; that will be picked up after a processing boundary.&lt;/P&gt;&lt;P&gt;In this case AFTER the datastep his run, the new code picked up and it will see:&amp;nbsp;&amp;nbsp;&amp;nbsp; class ... "=student ".... '&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;Not really valid code as there is nothing else.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 06:06:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184724#M35051</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-07-24T06:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration loops to macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184725#M35052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jaap,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Not quite understand.&amp;nbsp; I attached my SAS log output.&amp;nbsp; The new variables cannot be derived.&amp;nbsp; In this case, how could I write this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;jones&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 06:45:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184725#M35052</guid>
      <dc:creator>JonesSmith</dc:creator>
      <dc:date>2014-07-24T06:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration loops to macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184726#M35053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, here is part of the SAS Log.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;135&amp;nbsp; data dummy;&lt;BR /&gt;136&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set examine;&lt;BR /&gt;137&lt;BR /&gt;138&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put student1= student2= student3= student4= student5= student6= student7= student8= student9= student10=;&lt;BR /&gt;139&lt;BR /&gt;140&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do m=1 to 10;&lt;BR /&gt;141&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute("class" || strip(m) || "=student" || strip(m) || ";");&lt;BR /&gt;142&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;143&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 141:37&amp;nbsp;&amp;nbsp; 141:63&lt;BR /&gt;student1=123 student2=80 student3=118 student4=193 student5=328 student6=239 student7=107 student8=200 student9=80 student10=60&lt;BR /&gt;NOTE: There were 1 observations read from the data set WORK.EXAMINE.&lt;BR /&gt;NOTE: The data set WORK.DUMMY has 1 observations and 11 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NOTE: CALL EXECUTE generated line.&lt;BR /&gt;NOTE: Line generated by the CALL EXECUTE routine.&lt;BR /&gt;1&amp;nbsp;&amp;nbsp; + class1=student1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ------&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 180&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;NOTE: Line generated by the CALL EXECUTE routine.&lt;BR /&gt;2&amp;nbsp;&amp;nbsp; + class2=student2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ------&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 180&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 06:49:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184726#M35053</guid>
      <dc:creator>JonesSmith</dc:creator>
      <dc:date>2014-07-24T06:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration loops to macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184727#M35054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yep, as your read the log the data step is ready. When ready&amp;nbsp; it gives the processing information that is aflter that line 143.&lt;BR /&gt; Than new code to process is&amp;nbsp; coming in, it says where it is coming from (the execute statement). Getting no clue where that&amp;nbsp; " + class1=student1;&amp;nbsp; " should belong to.&lt;/P&gt;&lt;P&gt;There is no datastep running, no proc nothing. These assignments ..... where should they belong to?&amp;nbsp; "out of proper order" is a good error description.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 07:02:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184727#M35054</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-07-24T07:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration loops to macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184728#M35055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Japp,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Physically from the program and log, student1-student10 have been actually input in the dataset and class1-class10 will be the newly created variables afterwards.&amp;nbsp; But in the log, "+ class1=student1;" tells that it is used out of proper order.&amp;nbsp; Based on the normal syntax, it is correct and can be interpreted. Not quite understand why it cannot be resolved.&amp;nbsp; May I know how to manage it ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;jones&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 07:25:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184728#M35055</guid>
      <dc:creator>JonesSmith</dc:creator>
      <dc:date>2014-07-24T07:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration loops to macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184729#M35056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You cannot change code in your current executing datastep using subexec. T&lt;BR /&gt;hat code goes AFTER your datastep has been processed not in your datastep.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAS (base language) is an interpreter with a lot freedom but due the nature of eliminating the row awareness it must know all columns before processing starts. That is coming back with the PDV (program data vector). Forget a lot of other languages (Cobol Pascal java C) as this is an essential difference. Some other 4-5 Gl language doing the similar like RPC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is your real issue? Think to solve it with: &lt;BR /&gt;- The power of SAS-macro processing is it can change code in a programmatic way before code analyses starts. Tat is before all of that so it can define some variables dynamic.&lt;/P&gt;&lt;P&gt;- using arrays and variable lists. Maybe overallocating the number of processed variables &lt;/P&gt;&lt;P&gt;&amp;nbsp; Your description of what you want to do, is like that. &lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#n1dyr3r1mhtp1nn19mlftiwv0azf.htm" title="http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#n1dyr3r1mhtp1nn19mlftiwv0azf.htm"&gt;SAS(R) 9.3 Language Reference: Concepts, Second Edition&lt;/A&gt; (arrays conceptual view) &lt;/P&gt;&lt;P&gt;- ? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 07:43:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184729#M35056</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-07-24T07:43:50Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration loops to macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184730#M35057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am in meeting all day, so don't have much time.&amp;nbsp; Call execute is a code generator.&amp;nbsp; Basically you need to think about what you want as the final code, then you piece the information together into a string and that string is then sent out as code *after* your datastep code finishes.&amp;nbsp; Therefore as Jaap has said, the code you generate if you just put it into a new file would not execute and give those errors.&amp;nbsp; You need to build the full code:&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('data want; set have;'); /* send this line */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do I=1 to 10;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('attrib avar'||strip(put(I,best.))||";"); /* Send a line with an attrib statement for each do loop */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('run;'); /* Finish the code */&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will generate the code:&lt;/P&gt;&lt;P&gt;data want; set have;&lt;/P&gt;&lt;P&gt;attrib avar1;&lt;/P&gt;&lt;P&gt;attrib avar2;&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;You can do a similar thing with macro loops, its basically different methods for the same thing.&amp;nbsp; Both can be useful. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 08:00:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184730#M35057</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-07-24T08:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration loops to macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184731#M35058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many thanks to Jaap and RW9&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;jones&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 13:30:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteration-loops-to-macros/m-p/184731#M35058</guid>
      <dc:creator>JonesSmith</dc:creator>
      <dc:date>2014-07-24T13:30:44Z</dc:date>
    </item>
  </channel>
</rss>

