<?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 loop troubles in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446207#M111919</link>
    <description>&lt;P&gt;I'm not a fan of twenty questions. Please explain your process in detail.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The approach you're currently trying doesn't make sense for any process.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/123185"&gt;@GKati&lt;/a&gt; wrote:&lt;BR /&gt;It's variable.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Mar 2018 15:12:24 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-03-16T15:12:24Z</dc:date>
    <item>
      <title>DO loop troubles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446110#M111879</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a simple do-loop:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data nobs;&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; do i=i to 2;&lt;/P&gt;&lt;P&gt;data nobs_i;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;set nobs_i;&lt;/P&gt;&lt;P&gt;keep Nobsused;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is giving me the following error msg: No Matching DO/SELECT statement. Why?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 11:31:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446110#M111879</guid>
      <dc:creator>GKati</dc:creator>
      <dc:date>2018-03-16T11:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: DO loop troubles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446113#M111880</link>
      <description>&lt;P&gt;The second data statement begins a new data step, so the do in the old one has no matching end. What are you trying to do?&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 11:50:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446113#M111880</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-16T11:50:16Z</dc:date>
    </item>
    <item>
      <title>Re: DO loop troubles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446168#M111894</link>
      <description>I'm trying to figure out do-loops with a simple example. I have two datasets: nobs_1 and nobs_2. I would like to keep Nobsused in both datasets. Thanks&lt;BR /&gt;</description>
      <pubDate>Fri, 16 Mar 2018 14:04:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446168#M111894</guid>
      <dc:creator>GKati</dc:creator>
      <dc:date>2018-03-16T14:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: DO loop troubles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446172#M111897</link>
      <description>&lt;P&gt;The basic step would be&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data nobs;   
set
  nobs_1
  nobs_2
;
keep Nobsused;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you have an arbitrary number of datasets, use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set
  nobs_1-nobs_&amp;amp;n.
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;if your number of datasets is stored in macro variable n.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 14:10:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446172#M111897</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-16T14:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: DO loop troubles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446180#M111901</link>
      <description>Ok, this is helpful. But what if I wanted to keep the two datasets separete?</description>
      <pubDate>Fri, 16 Mar 2018 14:25:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446180#M111901</guid>
      <dc:creator>GKati</dc:creator>
      <dc:date>2018-03-16T14:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: DO loop troubles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446190#M111906</link>
      <description>&lt;P&gt;Back to the original question then, what are you trying to accomplish here?&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/123185"&gt;@GKati&lt;/a&gt; wrote:&lt;BR /&gt;Ok, this is helpful. But what if I wanted to keep the two datasets separete?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 14:43:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446190#M111906</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-16T14:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: DO loop troubles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446194#M111909</link>
      <description>I'm trying to figure out do-loops with a simple example. I have two datasets: nobs_1 and nobs_2. I would like to keep Nobsused in both datasets without merging the two datasets.&lt;BR /&gt;&lt;BR /&gt;I am going to have about 16 different datasets that I need to modify. I need to keep them separately and run a code through them one-by-one.&lt;BR /&gt;Thanks</description>
      <pubDate>Fri, 16 Mar 2018 14:50:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446194#M111909</guid>
      <dc:creator>GKati</dc:creator>
      <dc:date>2018-03-16T14:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: DO loop troubles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446200#M111913</link>
      <description>&lt;P&gt;What is NObsUsed?&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/123185"&gt;@GKati&lt;/a&gt; wrote:&lt;BR /&gt;I'm trying to figure out do-loops with a simple example. I have two datasets: nobs_1 and nobs_2. I would like to keep Nobsused in both datasets without merging the two datasets.&lt;BR /&gt;&lt;BR /&gt;I am going to have about 16 different datasets that I need to modify. I need to keep them separately and run a code through them one-by-one.&lt;BR /&gt;Thanks&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 14:59:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446200#M111913</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-16T14:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: DO loop troubles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446203#M111916</link>
      <description>It's variable.</description>
      <pubDate>Fri, 16 Mar 2018 15:03:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446203#M111916</guid>
      <dc:creator>GKati</dc:creator>
      <dc:date>2018-03-16T15:03:43Z</dc:date>
    </item>
    <item>
      <title>Re: DO loop troubles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446207#M111919</link>
      <description>&lt;P&gt;I'm not a fan of twenty questions. Please explain your process in detail.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The approach you're currently trying doesn't make sense for any process.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/123185"&gt;@GKati&lt;/a&gt; wrote:&lt;BR /&gt;It's variable.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 15:12:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446207#M111919</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-16T15:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: DO loop troubles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446214#M111922</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;If you goal is to understand do loops, you should start by looking at examples of its usage rather than trying to guess how they work.&lt;BR /&gt;&lt;BR /&gt;Do loops are used inside data steps and not  to iterate on several data steps, procs,...&lt;BR /&gt;&lt;BR /&gt;If you are interested in code generation you should learn SAS macro language but a minimal command of the base language is required to avoid confusion.</description>
      <pubDate>Fri, 16 Mar 2018 15:21:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446214#M111922</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-03-16T15:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: DO loop troubles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446216#M111924</link>
      <description>gamotte, Reeza&lt;BR /&gt;&lt;BR /&gt;Thanks for your help. My intention was not to waste your time. I have been looking at do-loop examples and that is how I came up with the code above. My intuition comes from STATA, where it is possible to loop over different datasets and modify them without merging them. I now understand that that is not possible in SAS and that I need to write a macro to do that. I will try that and see how I do.&lt;BR /&gt;Thanks for your time.&lt;BR /&gt;</description>
      <pubDate>Fri, 16 Mar 2018 15:26:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446216#M111924</guid>
      <dc:creator>GKati</dc:creator>
      <dc:date>2018-03-16T15:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: DO loop troubles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446223#M111927</link>
      <description>&lt;P&gt;If you state what you're trying to achieve we can recommend the best method.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, PROC DATASETS is more efficient to modify data sets to drop/keep variables that multiple data steps. If you take the approach used in other programming languages and try and apply them to another language, you miss learning how to efficiently use the new language.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or that you can easily create a view with just the one variable that only gets created when called.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/123185"&gt;@GKati&lt;/a&gt; wrote:&lt;BR /&gt;gamotte, Reeza&lt;BR /&gt;&lt;BR /&gt;Thanks for your help. My intention was not to waste your time. I have been looking at do-loop examples and that is how I came up with the code above. My intuition comes from STATA, where it is possible to loop over different datasets and modify them without merging them. I now understand that that is not possible in SAS and that I need to write a macro to do that. I will try that and see how I do.&lt;BR /&gt;Thanks for your time.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 15:38:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-loop-troubles/m-p/446223#M111927</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-16T15:38:40Z</dc:date>
    </item>
  </channel>
</rss>

