<?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: Lesson 4 Level 2 Practice: Processing Statements Conditionally with DO Groups in Programming 1 and 2</title>
    <link>https://communities.sas.com/t5/Programming-1-and-2/Lesson-4-Level-2-Practice-Processing-Statements-Conditionally/m-p/527850#M190</link>
    <description>Thanks novinosrin!</description>
    <pubDate>Wed, 16 Jan 2019 21:10:21 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-01-16T21:10:21Z</dc:date>
    <item>
      <title>Lesson 4 Level 2 Practice: Processing Statements Conditionally with DO Groups</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/Lesson-4-Level-2-Practice-Processing-Statements-Conditionally/m-p/527781#M183</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Proposed steps for Question1.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;data parks monuments;
    set pg1.np_summary;
  &lt;FONT color="#FF00FF"&gt;  where type in ('NM', 'NP');&lt;/FONT&gt;
    Campers= sum(OtherCamping, RVCampers, TentCampers, BackcountryCampers);
format campers comma20.;
length Parktype $ 8;
if type='NP' then do parktype= 'Park';
output parks;
end;
else if type='NM' then do parktype='Monument';
output monuments;
end;
run;&lt;/PRE&gt;&lt;P&gt;I don't understand why we would use code in pink? It made more sense for me to do the below code in red and not include the where type in statement? Also, I included my answer for question2. Instead of having to figure out exactly how many digits the sum will contain, is it ok to simply use a high number (20) and see if any data is missing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My code:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;data parks monuments;&lt;BR /&gt;set PG1.NP_SUMMARY;&lt;BR /&gt;campers= sum(OtherCamping, RVCampers, TentCampers, BackcountryCampers);&lt;BR /&gt;&lt;FONT color="#000000"&gt;format campers comma20.;&lt;/FONT&gt;&lt;BR /&gt;length Parktype $ 8;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;if Type= 'NP' then do Parktype='Park';&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;output parks;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;end;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;else if type='NM' then do ParkType='Monument';&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;output monuments;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;end;&lt;/FONT&gt;&lt;BR /&gt;keep Reg ParkName DayVisits OtherCamping Campers ParkType;&lt;BR /&gt;run; &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jan 2019 18:23:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/Lesson-4-Level-2-Practice-Processing-Statements-Conditionally/m-p/527781#M183</guid>
      <dc:creator>melissagodfrey</dc:creator>
      <dc:date>2019-01-16T18:23:47Z</dc:date>
    </item>
    <item>
      <title>Re: Lesson 4 Level 2 Practice: Processing Statements Conditionally with DO Groups</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/Lesson-4-Level-2-Practice-Processing-Statements-Conditionally/m-p/527782#M184</link>
      <description>Both of those are wrong.</description>
      <pubDate>Wed, 16 Jan 2019 18:28:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/Lesson-4-Level-2-Practice-Processing-Statements-Conditionally/m-p/527782#M184</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-16T18:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: Lesson 4 Level 2 Practice: Processing Statements Conditionally with DO Groups</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/Lesson-4-Level-2-Practice-Processing-Statements-Conditionally/m-p/527785#M185</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if Type= 'NP' then 
    do;
          Parktype='Park';
          output parks;
    end;
else if type='NM' then 
    do;
        ParkType='Monument';
        output monuments;
  end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Jan 2019 18:31:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/Lesson-4-Level-2-Practice-Processing-Statements-Conditionally/m-p/527785#M185</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-16T18:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: Lesson 4 Level 2 Practice: Processing Statements Conditionally with DO Groups</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/Lesson-4-Level-2-Practice-Processing-Statements-Conditionally/m-p/527790#M186</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I don't understand why we would use code in pink? It made more sense for me to do the below code in red and not include the where type in statement? &lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;For this trivial example, it likely doesn't matter, however, it is inefficient. If you'll only be working with two types, reducing your data set to just those two types means it will be faster since you have less records to process.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Also, I included my answer for question2. Instead of having to figure out exactly how many digits the sum will contain, is it ok to simply use a high number (20) and see if any data is missing?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, this is fine and a common thing to do.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As mentioned before, both pieces of code are incorrect and I'd expect you to get syntax errors. You have END statements but no DO statements that match. If you have a DO statement with something after DO, then it doesn't enter a DO/END situation, it does that command and the DO is finished. Review the documentation for a DO/END and DO statements.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jan 2019 18:35:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/Lesson-4-Level-2-Practice-Processing-Statements-Conditionally/m-p/527790#M186</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-16T18:35:05Z</dc:date>
    </item>
    <item>
      <title>Re: Lesson 4 Level 2 Practice: Processing Statements Conditionally with DO Groups</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/Lesson-4-Level-2-Practice-Processing-Statements-Conditionally/m-p/527812#M187</link>
      <description>&lt;P&gt;A few comments ....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code in &lt;FONT color="#FF0000"&gt;red&lt;/FONT&gt; works (as you have probably seen by now), but would look strange to most programmers.&amp;nbsp; The suggestion by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;is the more common way of specifying a DO group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why use the code in &lt;FONT color="#FF00FF"&gt;pink&lt;/FONT&gt;?&amp;nbsp; It is mainly a matter of efficiency.&amp;nbsp; Consider the contents of the incoming data.&amp;nbsp; Maybe that data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;contains 5,000 variables&lt;/LI&gt;
&lt;LI&gt;contains 1,000 different values for TYPE&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;In that case, much of the work of the DATA step would be reading in data that we never need.&amp;nbsp; The WHERE statement allows SAS to inspect the data before reading it in.&amp;nbsp; The DATA step never needs to read in the data that it doesn't need, saving time.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jan 2019 19:36:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/Lesson-4-Level-2-Practice-Processing-Statements-Conditionally/m-p/527812#M187</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-01-16T19:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: Lesson 4 Level 2 Practice: Processing Statements Conditionally with DO Groups</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/Lesson-4-Level-2-Practice-Processing-Statements-Conditionally/m-p/527821#M188</link>
      <description>thnx for the response.&lt;BR /&gt;&lt;BR /&gt;i got 0 syntax errors. the first piece of code is the answer from SAS. the second piece of code is my response. both yielded the same exact results.</description>
      <pubDate>Wed, 16 Jan 2019 20:06:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/Lesson-4-Level-2-Practice-Processing-Statements-Conditionally/m-p/527821#M188</guid>
      <dc:creator>melissagodfrey</dc:creator>
      <dc:date>2019-01-16T20:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: Lesson 4 Level 2 Practice: Processing Statements Conditionally with DO Groups</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/Lesson-4-Level-2-Practice-Processing-Statements-Conditionally/m-p/527827#M189</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;Good afternoon, The reason there isn't any syntax errors is becuase sas treats the do statement as "do iterative" rather than a conditional do group. Not needed but funny&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
/*iterate once*/

data w;
set sashelp.class;
if sex='F' then do gender='Female';
end;
run;

/*iterate more than once below*/


data w;
set sashelp.class;
if sex='F' then do gender='Female',"fem";
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Jan 2019 20:16:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/Lesson-4-Level-2-Practice-Processing-Statements-Conditionally/m-p/527827#M189</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-16T20:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: Lesson 4 Level 2 Practice: Processing Statements Conditionally with DO Groups</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/Lesson-4-Level-2-Practice-Processing-Statements-Conditionally/m-p/527850#M190</link>
      <description>Thanks novinosrin!</description>
      <pubDate>Wed, 16 Jan 2019 21:10:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/Lesson-4-Level-2-Practice-Processing-Statements-Conditionally/m-p/527850#M190</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-16T21:10:21Z</dc:date>
    </item>
  </channel>
</rss>

