<?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: call execute in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/254419#M48523</link>
    <description>&lt;P&gt;Your original question is answered. Please post new questions in a new thread.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Mar 2016 07:58:20 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-03-04T07:58:20Z</dc:date>
    <item>
      <title>looping over the information included in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/253074#M48115</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dear all:&lt;/P&gt;&lt;P&gt;I want to create a little macro(example loop) &amp;nbsp;&amp;nbsp;that loops over each of the dates in the first column of the below&amp;nbsp; table; I would like to understand how I can link the information in the date column in the excel file in order to create a macro that creates sub-samples based on the dates. For example,a code like this, where there is macro within a macro etc..&lt;/P&gt;&lt;P&gt;My question is how to use the date information in the table (pls see column in the attached excel file) so that the macro loops over each row in the column one-by-one.This is important as the information I am processing has huge number of rows&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;The macro in which I want the use information in Column 1:&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro &amp;nbsp;example loop(date,y);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Data a_&amp;amp;y&amp;nbsp;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set b&amp;nbsp;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Where date=&amp;amp;date&amp;nbsp;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Proc reg data=a_&amp;amp;y;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Model whatever&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Out=result_&amp;amp;y&lt;/P&gt;&lt;P&gt;&amp;nbsp;%anothermacro(result_&amp;amp;y)&lt;/P&gt;&lt;P&gt;……&lt;/P&gt;&lt;P&gt;%mend exampleloop:&lt;/P&gt;</description>
      <pubDate>Sun, 28 Feb 2016 22:01:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/253074#M48115</guid>
      <dc:creator>Sonyboy</dc:creator>
      <dc:date>2016-02-28T22:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: looping over the information included in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/253075#M48116</link>
      <description>Assuming that your tables data is in a SAS data set. &lt;BR /&gt;Use a data step and use CALL EXECUTE.&lt;BR /&gt;To optimize your macro, I'm pretty sure you could use WHERE with proc reg, so you can avoid the extra subsetting step.</description>
      <pubDate>Sun, 28 Feb 2016 22:08:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/253075#M48116</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-02-28T22:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: looping over the information included in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/253076#M48117</link>
      <description>&lt;P&gt;Also, why not use BY processing?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.stocks out=stocks;
by stock date;
run;

proc reg data=stocks;
by stock;
model close = open;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 28 Feb 2016 22:33:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/253076#M48117</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-28T22:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: looping over the information included in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/253089#M48118</link>
      <description>&lt;P&gt;Dear Reeza,&lt;/P&gt;&lt;P&gt;thank you. However, in this case, the data set shown in the excel file and the data set "a" that I use in the prog reg are two separate and independent data sets. The only information that I would like to use from the excel file is the list of dates...otherwise the data to be used in the reg has no similarity with the data that I use within the macro in the proc reg.&lt;/P&gt;&lt;P&gt;the idea is to bring in each of these dates in the macro ...is this now clearer?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Feb 2016 23:47:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/253089#M48118</guid>
      <dc:creator>Sonyboy</dc:creator>
      <dc:date>2016-02-28T23:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: looping over the information included in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/253091#M48119</link>
      <description>please see my comment to Reeza. I have a list emanating from a completely distinct dataset. The dataset I use in the macro are totally different from the one I show in the excel file. The only common point is that the list of dates. I want to use this excel list in another macro as an input to a looping process. As a matter of fact, for each date in the excel, I want the create a subset data through "where" and run the analysis...Can you please give me a code example of what you have in mind?&lt;BR /&gt;</description>
      <pubDate>Mon, 29 Feb 2016 00:00:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/253091#M48119</guid>
      <dc:creator>Sonyboy</dc:creator>
      <dc:date>2016-02-29T00:00:58Z</dc:date>
    </item>
    <item>
      <title>Re: looping over the information included in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/253093#M48120</link>
      <description>Create a data that contains the entire list and then use BY. &lt;BR /&gt;&lt;BR /&gt;If you really want a macro, then call execute is what your looking for. The documentation has a good example of the usage.</description>
      <pubDate>Mon, 29 Feb 2016 00:35:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/253093#M48120</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-29T00:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: looping over the information included in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/253140#M48134</link>
      <description>&lt;P&gt;I would agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;here. &amp;nbsp;Create a dataset of your dates for this Excel file. &amp;nbsp;Then do one step:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table WANT as
  select *
  from   HAVE
  where DATE in (select date from DATES_DATASET);
quit;&lt;/PRE&gt;
&lt;P&gt;This then creates a dataset called want, which only has the dates in the list from Excel. &amp;nbsp;Then run whatever procedure you want there after with a by group on the date variable. &amp;nbsp;By group processing is far quicker than running the procedure for each set, and is far easier to read than messy unecessary macro code.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Feb 2016 09:33:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/253140#M48134</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-02-29T09:33:25Z</dc:date>
    </item>
    <item>
      <title>call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/254019#M48393</link>
      <description>&lt;P&gt;Dear Reeza et all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to get the following macro work. However, the system does not recognize this...&lt;/P&gt;&lt;P&gt;'am' is simply a list of numbers....&lt;/P&gt;&lt;P&gt;the macro %soner(x) &amp;nbsp;works &amp;nbsp;when ones run it in the format of %soner(1) etc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;however, the below macro does not function properly neither with&amp;nbsp;&lt;SPAN&gt;|| or without it...When I do not put&amp;nbsp;|| them it simply takes on the the character variable am...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How can I fix this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;set index;&lt;BR /&gt;call execute("%soner('||am||')");&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2016 23:59:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/254019#M48393</guid>
      <dc:creator>Sonyboy</dc:creator>
      <dc:date>2016-03-02T23:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/254030#M48396</link>
      <description>&lt;P&gt;I don't think you're passing the correct string to call execute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try creating the string outside of the call execute, make sure it looks correct and then either move that code to your call execute or pass it the variable name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, don't use double quotes when building your string for call execute. It will try and resolve the macro, which you don't want it to do and will generate warnings in your log.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2016 01:54:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/254030#M48396</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-03T01:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/254097#M48419</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, can I ask why the solution I provided does not work for you. &amp;nbsp;It is far better to use Base SAS programming and by groups for both efficiency and ease of programming. &amp;nbsp;Macro language is not designed as a replacement for this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Secondly, you make no examplpe in your post of what this "index" dataset looks like or contains. &amp;nbsp;For a full answer always provide example test data in the form of a datastep so we can see what your working with. &amp;nbsp;I will guess that it looks like this:&lt;/P&gt;
&lt;P&gt;Index:&lt;/P&gt;
&lt;P&gt;Var=Am=Numeric&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;P&gt;3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, you can consider the datastep to be a loop, each iteration happens over one observation at a time. Call execute function accepts a valid string, i.e. characters enclosed in quotes, and this gets pushed out to the compiler after the datastep finishes execution. &amp;nbsp;That text then of course, has to be valid SAS code. &amp;nbsp;So what will this line generate:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;call execute("%soner('||am||')");&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if numeric 1 is placed in there - remember there is padding in a variable:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%soner(' &amp;nbsp; &amp;nbsp; 1')&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;something like that. &amp;nbsp;So I would suggest something like:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;data index;&lt;BR /&gt; am=1; output;&lt;BR /&gt; am=2; output;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;%macro soner(a);&lt;BR /&gt;%mend soner;&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt; set index;&lt;BR /&gt; call execute(cats('%soner(',put(am,1.),');'));&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;What this should do&amp;nbsp;is create two extra rows in the code which call the macro twice. &amp;nbsp;However, all of this can be avoided by simply using by groups.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2016 09:22:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/254097#M48419</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-03-03T09:22:29Z</dc:date>
    </item>
    <item>
      <title>Re: call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/254318#M48487</link>
      <description>&lt;P&gt;thank you so much. This worked brilliantly.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2016 20:39:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/254318#M48487</guid>
      <dc:creator>Sonyboy</dc:creator>
      <dc:date>2016-03-03T20:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/254383#M48505</link>
      <description>&lt;P&gt;Hello there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;with the call execute step, if one step is taking too much time and blocking all the steps, how can I tell the system to move on after a while..How can I integrate this into the below piece fo the codeIs there a timeout option?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data _null_;&lt;BR /&gt; set index;&lt;BR /&gt; call execute(cats('%soner(',put(am,1.),');'));&lt;BR /&gt;run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;thanks for your response&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2016 00:03:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/254383#M48505</guid>
      <dc:creator>Sonyboy</dc:creator>
      <dc:date>2016-03-04T00:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/254413#M48522</link>
      <description>&lt;P&gt;Just some further information for the above question.&lt;/P&gt;&lt;P&gt;for example in the above code,let'us assume the two consecutive values are 2; 103 in the index.let's assume that for the value=2, the %macro just turns in an infinite manner...I want to tell the system that if there are no results after some time, I want it to move the next value=103...&lt;/P&gt;&lt;P&gt;how can I achieve this?&lt;/P&gt;&lt;P&gt;thank you&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2016 06:23:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/254413#M48522</guid>
      <dc:creator>Sonyboy</dc:creator>
      <dc:date>2016-03-04T06:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/254419#M48523</link>
      <description>&lt;P&gt;Your original question is answered. Please post new questions in a new thread.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2016 07:58:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/254419#M48523</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-04T07:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/254423#M48525</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will respond here, but as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;has stated this is a new topic. &amp;nbsp;Let me first explain what Base SAS and Macro SAS are:&lt;/P&gt;
&lt;P&gt;Base SAS is compiled code which operates on data to process and manipulate the data.&lt;/P&gt;
&lt;P&gt;Macro SAS is a code generation tool, to help repeat typing of code.&lt;/P&gt;
&lt;P&gt;The call execute has no impact whatsoever on operation time of the Base SAS code you have programmed or generated from code. &amp;nbsp;Nor will it have any control over it. &amp;nbsp;The reason being, well the code that feeds into the compiler - that which actually does something to the data, is already fully expanded by the pre-processor (the macro compiler if you will), and none of that remains, so cannot know how long a step takes to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now we know what the two let me ask you the question I asked a couple of times before in this post, and that is why are you not using Base SAS programming to do you processing, what "need" is there for code generation and macro processing? &amp;nbsp;If you write your Base SAS code efficiently - i.e. using by groups and such like - this reduces the number of load/close for each of the files. &amp;nbsp;It will make your code far more readable (and if you have ever had to pick up someones else code you will know what I am talking about), far more efficient, and far more maintainable. &amp;nbsp;In 99% of the time cases Base SAS can do what you want, though it may require sideways thinking e.g. restructuring data. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Onto the question, this is down to what is happening in your macro, you haven't posted it, so I have no idea. &amp;nbsp;You can't conditionally stop a datastep running based on resource use (at least easily), it is one step which runs, then the next one etc. &amp;nbsp;Optimise your code - see the paragraph above here - write efficient Base SAS code. &amp;nbsp;Once that is running efficiently, then look at seeing if you can reduce the code somewhat with Macro. &amp;nbsp;Don't just write macro programs to cover up the lack of Base SAS programming.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without further example I can't say much else.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2016 09:22:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/looping-over-the-information-included-in-a-column/m-p/254423#M48525</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-03-04T09:22:04Z</dc:date>
    </item>
  </channel>
</rss>

