<?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: using macro variables to subset data in procedures in SAS Academy for Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/using-macro-variables-to-subset-data-in-procedures/m-p/664587#M916</link>
    <description>&lt;P&gt;Hi and welcome to the communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess you want to avoid repeating the same statement all over. See this example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let wherecond = where species_Id like “YOSE%” and Category = “Mammal”;

proc freq data=pg1.np_species;
tables Abundance Conservation_Status;
&amp;amp;wherecond.;
run;

proc print data= pg1.np_soecies
var species _id category scientific _Name common names;
&amp;amp;wherecond.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To avoid problems if you do not want a where condition, define the macro variable as empty:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let wherecond=;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 24 Jun 2020 09:01:38 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-06-24T09:01:38Z</dc:date>
    <item>
      <title>using macro variables to subset data in procedures</title>
      <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/using-macro-variables-to-subset-data-in-procedures/m-p/664585#M915</link>
      <description>&lt;P&gt;Proc freq data=pg1.np_species;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tables Abundance Conservation_Status;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;where species_ID likes”YOSE%” and&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Category=“Mammal&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print data= pg1.np_soecies&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Var species _id category scientific _Name common names;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Where species_Id likes “YOSE%” and&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Category =“Mammal”;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 08:52:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/using-macro-variables-to-subset-data-in-procedures/m-p/664585#M915</guid>
      <dc:creator>Nischala</dc:creator>
      <dc:date>2020-06-24T08:52:26Z</dc:date>
    </item>
    <item>
      <title>Re: using macro variables to subset data in procedures</title>
      <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/using-macro-variables-to-subset-data-in-procedures/m-p/664587#M916</link>
      <description>&lt;P&gt;Hi and welcome to the communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess you want to avoid repeating the same statement all over. See this example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let wherecond = where species_Id like “YOSE%” and Category = “Mammal”;

proc freq data=pg1.np_species;
tables Abundance Conservation_Status;
&amp;amp;wherecond.;
run;

proc print data= pg1.np_soecies
var species _id category scientific _Name common names;
&amp;amp;wherecond.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To avoid problems if you do not want a where condition, define the macro variable as empty:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let wherecond=;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Jun 2020 09:01:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/using-macro-variables-to-subset-data-in-procedures/m-p/664587#M916</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-24T09:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: using macro variables to subset data in procedures</title>
      <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/using-macro-variables-to-subset-data-in-procedures/m-p/664670#M917</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; This question is more of a SAS Programming 1 question, not a Data Science question. In the future if you have class questions, you might consider posting them in the forum that we have specfically for Programming 1 students. Here's that link for future reference: &lt;A href="https://communities.sas.com/t5/Programming-1-and-2/bd-p/course_discussions" target="_blank"&gt;https://communities.sas.com/t5/Programming-1-and-2/bd-p/course_discussions&lt;/A&gt; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; For the problem that you're working on, our intention is to show students simple uses for macro variables.&amp;nbsp; We start the practice slowly by making sure that the students have coded the correct WHERE statements and have them try the WHERE in 2 different procedures:&lt;/P&gt;
&lt;DIV id="tinyMceEditorCynthia_sas_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tinyMceEditorCynthia_sas_2" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp; Then, after they have working code, we want them to keep going and define macro variables:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="level2_chap3_part2.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/46580iFD555E9B1D48959E/image-size/large?v=v2&amp;amp;px=999" role="button" title="level2_chap3_part2.png" alt="level2_chap3_part2.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; The purpose is to show the utility of macro variables and while building an entire WHERE condition is efficient, we didn't include that approach in the beginning Programmign course. We save something like that for the Macro 1 and Macro 2 courses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps explain our approach with this Practice and why there are 2 where statements.&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="tinyMceEditorCynthia_sas_1" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 15:34:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/using-macro-variables-to-subset-data-in-procedures/m-p/664670#M917</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2020-06-24T15:34:38Z</dc:date>
    </item>
  </channel>
</rss>

