<?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: Subset data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Subset-data/m-p/592076#M169725</link>
    <description>&lt;P&gt;PRINT only displays your data, subset your data means create a new dataset with certain, specific, records from the main data set. &lt;BR /&gt;&lt;BR /&gt;Your use of macro variables is incorrect. &lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a tutorial on filtering data:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://video.sas.com/detail/video/4573016761001/filtering-a-sas-table-in-a-data-step?autoStart=true&amp;amp;page=1&amp;amp;q=filter" target="_blank"&gt;https://video.sas.com/detail/video/4573016761001/filtering-a-sas-table-in-a-data-step?autoStart=true&amp;amp;page=1&amp;amp;q=filter&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And here's a tutorial on macros/macro variables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;UCLA introductory tutorial on macro variables and macros&lt;/H2&gt;
&lt;P&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/" rel="nofollow" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/&lt;/A&gt;&lt;/P&gt;
&lt;H2&gt;&lt;A id="user-content-tutorial-on-converting-a-working-program-to-a-macro" class="anchor" href="https://github.com/statgeek/SAS-Tutorials#tutorial-on-converting-a-working-program-to-a-macro" aria-hidden="true" target="_blank"&gt;&lt;/A&gt;Tutorial on converting a working program to a macro&lt;/H2&gt;
&lt;P&gt;This method is pretty robust and helps prevent errors and makes it much easier to debug your code. Obviously biased, because I wrote it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md" target="_blank"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md&lt;/A&gt;&lt;/P&gt;
&lt;H2&gt;&lt;A id="user-content-examples-of-common-macro-usage" class="anchor" href="https://github.com/statgeek/SAS-Tutorials#examples-of-common-macro-usage" aria-hidden="true" target="_blank"&gt;&lt;/A&gt;Examples of common macro usage&lt;/H2&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716" rel="nofollow" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Sep 2019 04:09:46 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-09-27T04:09:46Z</dc:date>
    <item>
      <title>Subset data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-data/m-p/592048#M169711</link>
      <description>&lt;P&gt;Hi, please help me with the code for the following problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create a temporary SAS table (I named it sportoutput), read in the worksheet (Sport_List)from the library. Subset the data for a given sport of your choice and use a macro variable to specify the sport. Also, subset data where Sport is Football, Soccer, Basketball or Table Tennis.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I have so far:&lt;/P&gt;&lt;P&gt;data sportoutput;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; set Sport_List;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%Let Sport=Basketball;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; proc print data=Sport_List;&lt;BR /&gt;where Sport="Basketball";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2019 22:42:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-data/m-p/592048#M169711</guid>
      <dc:creator>aabbccwyt</dc:creator>
      <dc:date>2019-09-26T22:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: Subset data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-data/m-p/592051#M169713</link>
      <description>&lt;P&gt;The way you point to the excel&amp;nbsp;&lt;SPAN&gt;worksheet&amp;nbsp;is wrong. You must define a library. Read your course notes again.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2019 22:52:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-data/m-p/592051#M169713</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-09-26T22:52:50Z</dc:date>
    </item>
    <item>
      <title>Re: Subset data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-data/m-p/592069#M169720</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*This subsets data where Sport is Football, Soccer, Basketball or Table Tennis*/
data Sport_List_Football Sport_List_Soccer Sport_List_Basketball Sport_List_Table_Tennis;
set Sport_List;
if Sport="Football" then output Sport_List_Football;
if Sport="Soccer" then output Sport_List_Soccer;
if Sport="Basketball" then output Sport_List_Basketball;
if Sport="Table Tennis" then output Sport_List_Table_Tennis;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Sep 2019 03:13:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-data/m-p/592069#M169720</guid>
      <dc:creator>sustagens</dc:creator>
      <dc:date>2019-09-27T03:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: Subset data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-data/m-p/592076#M169725</link>
      <description>&lt;P&gt;PRINT only displays your data, subset your data means create a new dataset with certain, specific, records from the main data set. &lt;BR /&gt;&lt;BR /&gt;Your use of macro variables is incorrect. &lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a tutorial on filtering data:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://video.sas.com/detail/video/4573016761001/filtering-a-sas-table-in-a-data-step?autoStart=true&amp;amp;page=1&amp;amp;q=filter" target="_blank"&gt;https://video.sas.com/detail/video/4573016761001/filtering-a-sas-table-in-a-data-step?autoStart=true&amp;amp;page=1&amp;amp;q=filter&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And here's a tutorial on macros/macro variables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;UCLA introductory tutorial on macro variables and macros&lt;/H2&gt;
&lt;P&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/" rel="nofollow" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/&lt;/A&gt;&lt;/P&gt;
&lt;H2&gt;&lt;A id="user-content-tutorial-on-converting-a-working-program-to-a-macro" class="anchor" href="https://github.com/statgeek/SAS-Tutorials#tutorial-on-converting-a-working-program-to-a-macro" aria-hidden="true" target="_blank"&gt;&lt;/A&gt;Tutorial on converting a working program to a macro&lt;/H2&gt;
&lt;P&gt;This method is pretty robust and helps prevent errors and makes it much easier to debug your code. Obviously biased, because I wrote it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md" target="_blank"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md&lt;/A&gt;&lt;/P&gt;
&lt;H2&gt;&lt;A id="user-content-examples-of-common-macro-usage" class="anchor" href="https://github.com/statgeek/SAS-Tutorials#examples-of-common-macro-usage" aria-hidden="true" target="_blank"&gt;&lt;/A&gt;Examples of common macro usage&lt;/H2&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716" rel="nofollow" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2019 04:09:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-data/m-p/592076#M169725</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-09-27T04:09:46Z</dc:date>
    </item>
  </channel>
</rss>

