<?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: %do without using %to in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368280#M87817</link>
    <description>&lt;P&gt;i want to pick selective data by using :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro x();&lt;/P&gt;
&lt;P&gt;%do i = 3 ,6, 7,9;&lt;/P&gt;
&lt;P&gt;proc report data= Ivalue_&amp;amp;i;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Jun 2017 12:40:41 GMT</pubDate>
    <dc:creator>Aman4SAS</dc:creator>
    <dc:date>2017-06-19T12:40:41Z</dc:date>
    <item>
      <title>%do without using %to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368258#M87804</link>
      <description>&lt;P&gt;Hi team,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;we need help in sas macro&lt;/P&gt;
&lt;P&gt;&amp;nbsp;if we can use below&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;do i = 2, 5, 7 ;&lt;BR /&gt;x=i;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so what we can not use&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro x();&lt;/P&gt;
&lt;P&gt;%do i=3,6,8;&lt;/P&gt;
&lt;P&gt;statements;&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;%x;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 12:06:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368258#M87804</guid>
      <dc:creator>Aman4SAS</dc:creator>
      <dc:date>2017-06-19T12:06:28Z</dc:date>
    </item>
    <item>
      <title>Re: %do without using %to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368262#M87807</link>
      <description>&lt;P&gt;Macro language is NOT meant for data processing. Write this 100 times.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 12:10:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368262#M87807</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-06-19T12:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: %do without using %to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368263#M87808</link>
      <description>&lt;P&gt;I apology if i did mistake.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But i need to run my programe for selective day. and i want to run my do loop for that.&lt;/P&gt;
&lt;P&gt;but i am getting error that u r missing %to. So is there any possibility that i can use %do with out using %to.???&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 12:17:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368263#M87808</guid>
      <dc:creator>Aman4SAS</dc:creator>
      <dc:date>2017-06-19T12:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: %do without using %to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368273#M87813</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;has mentioned, Macro language is only present to generate text, it does not do any processing. &amp;nbsp;Therefore constructs used in Base SAS which is the programming language do not always carry through to Macro. &amp;nbsp;Do list of values is one of these constructs. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe we have been over this several times before. &amp;nbsp;Do data processing in Base SAS, that is what it is for. &amp;nbsp;What is it your trying to do with this code?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 12:31:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368273#M87813</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-19T12:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: %do without using %to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368274#M87814</link>
      <description>&lt;P&gt;Post the code you want to run for a series of days, showing how the days are represented in the code as is (for a single run), and from where you will get the days for the dynamic execution (dataset?).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When writing repeatable code, follow this sequence:&lt;/P&gt;
&lt;P&gt;- write code for one iteration&lt;/P&gt;
&lt;P&gt;- identify variable parts&lt;/P&gt;
&lt;P&gt;- replace with macro values&lt;/P&gt;
&lt;P&gt;- create a means to supply these values (macro %do loop, datastep with call execute, ...) repeatedly&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 12:32:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368274#M87814</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-06-19T12:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: %do without using %to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368280#M87817</link>
      <description>&lt;P&gt;i want to pick selective data by using :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro x();&lt;/P&gt;
&lt;P&gt;%do i = 3 ,6, 7,9;&lt;/P&gt;
&lt;P&gt;proc report data= Ivalue_&amp;amp;i;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 12:40:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368280#M87817</guid>
      <dc:creator>Aman4SAS</dc:creator>
      <dc:date>2017-06-19T12:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: %do without using %to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368282#M87819</link>
      <description>&lt;P&gt;The %DO command does not have all of the functionality of the DO command.&lt;/P&gt;
&lt;P&gt;To process a list I usually put the list into a macro variable and use %SCAN() to pull the individual items.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro x(list);
%local i value ;
%do i=1 %to %sysfunc(countw(&amp;amp;list));
  %let value = %scan(&amp;amp;list,&amp;amp;i);
   statements using &amp;amp;value ;
%end;
%mend;
%x(2 5 7);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Jun 2017 12:46:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368282#M87819</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-19T12:46:44Z</dc:date>
    </item>
    <item>
      <title>Re: %do without using %to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368294#M87823</link>
      <description>&lt;P&gt;Thanks for ur answer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i have done same as alternate option.&lt;/P&gt;
&lt;P&gt;%let list=13|14|15|25|26|27;&lt;BR /&gt;%do part = 1 %to 6;&lt;BR /&gt;%let i=%scan(&amp;amp;list,&amp;amp;part,%str(|));&lt;BR /&gt;%put &amp;amp;i;&lt;BR /&gt;%end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but for future prospect i want study this more. bcaz i have tried "in" with %do same also does not work. is there any document so i can study more for the same.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance for all of ur advice.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 12:55:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368294#M87823</guid>
      <dc:creator>Aman4SAS</dc:creator>
      <dc:date>2017-06-19T12:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: %do without using %to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368295#M87824</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data control;
input i;
cards;
3
6
7
9
;
run;

%macro x(i);
proc report data= Ivalue_&amp;amp;i;
run;
%mend;

data _null_;
set control;
call execute('%x(' !! strip(put(i,best.)) !! ') ');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Jun 2017 12:57:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368295#M87824</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-06-19T12:57:47Z</dc:date>
    </item>
    <item>
      <title>Re: %do without using %to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368308#M87827</link>
      <description>&lt;P&gt;Note there is no need to use %STR() around | as it is not a macro trigger. That is one good reason to use it as the delimiter in a list of values. &amp;nbsp;Personally I much prefer to use spaces as delimiters since it is much easier to type and read, but that can be a problem if the values can contain spaces. &amp;nbsp;If your values can contain other default delimiters for %SCAN() then you do need to use the third argument to %SCAN() to let it know what specific delimiter(s) to use. &amp;nbsp;There is also a fourth argument to %SCAN() that can be used to add modifiers to control how it parses the string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The IN operator is just a method for testing if a value appears in a list a values. Not sure what it would have to do with a DO loop. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that there are limitations on using the IN operator within macro code since it was not originally recognized as a keyword by the macro processor. &amp;nbsp;There are system options and options on the %MACRO statement to control whether and how the IN operator works in macro code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SAS documentation is on-line at sas.com. &amp;nbsp;I usually just GOOGLE until I find the right document and then look around.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 13:25:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368308#M87827</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-19T13:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: %do without using %to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368323#M87831</link>
      <description>And, in addition to all of these excellent suggestions, here's an overview of Macro processing and how it works to get you started reading about why you don't confuse DO processing with %DO processing:&lt;BR /&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings13/120-2013.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings13/120-2013.pdf&lt;/A&gt;&lt;BR /&gt;cynthia</description>
      <pubDate>Mon, 19 Jun 2017 13:38:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368323#M87831</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-06-19T13:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: %do without using %to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368324#M87832</link>
      <description>&lt;P&gt;&amp;nbsp;If you do want to use %do loop, you could try this:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;option minoperator mindelimiter='|';&lt;/P&gt;
&lt;P&gt;%macro test;&lt;BR /&gt;%let list=13|14|15|25|26|27;&lt;BR /&gt;%do part = 1 %to 30;&lt;BR /&gt;%if &amp;amp;part in &amp;amp;list %then &lt;BR /&gt;%put &amp;amp;part;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;
&lt;P&gt;%test;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 13:40:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/368324#M87832</guid>
      <dc:creator>slchen</dc:creator>
      <dc:date>2017-06-19T13:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: %do without using %to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/370422#M88452</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/47932"&gt;@slchen&lt;/a&gt; It's a good habit to declare your variables as local. You'll save yourself many headaches.&lt;/P&gt;
&lt;P&gt;So this is a (slightly) better macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%macro test/minoperator mindelimiter='|';
  %local list part;
  %let list=13|14|15|25|26|27;
  %do part = 1 %to 30;
    %if &amp;amp;part in &amp;amp;list %then %put &amp;amp;=part;
  %end;
%mend;

%test;


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Jun 2017 03:51:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-without-using-to/m-p/370422#M88452</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-06-26T03:51:01Z</dc:date>
    </item>
  </channel>
</rss>

