<?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: Subsetting a dataset using Macro in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting-a-dataset-using-Macro/m-p/191444#M48175</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;where index(score, "&amp;amp;value");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;---&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;if index(score, "&amp;amp;value");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;OR&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;where score contains "&amp;amp;value";&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 24 Apr 2014 09:13:07 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2014-04-24T09:13:07Z</dc:date>
    <item>
      <title>Subsetting a dataset using Macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting-a-dataset-using-Macro/m-p/191443#M48174</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am having issue while subsetting a dataset using Macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here is my code :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro dt (value);&lt;/P&gt;&lt;P&gt;data raw_new;&lt;/P&gt;&lt;P&gt;set raw;&lt;/P&gt;&lt;P&gt;where index(score, "&amp;amp;value");&lt;/P&gt;&lt;P&gt;%dt(apple_1);&lt;/P&gt;&lt;P&gt;%dt(orange_2);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From Raw data set I want to create raw_new data set. Variable score has 1000 values and I want to keep only those values which contains "apple_1" and "orange_2". Every time I run this code, I get only values with orange_2 in my dataset. apple_1 does not get appended to orange_2. Could you please suggest what I'm doing wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank You!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Apr 2014 06:23:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting-a-dataset-using-Macro/m-p/191443#M48174</guid>
      <dc:creator>Pujasharma</dc:creator>
      <dc:date>2014-04-24T06:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting a dataset using Macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting-a-dataset-using-Macro/m-p/191444#M48175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;where index(score, "&amp;amp;value");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;---&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;if index(score, "&amp;amp;value");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;OR&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;where score contains "&amp;amp;value";&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Apr 2014 09:13:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting-a-dataset-using-Macro/m-p/191444#M48175</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-04-24T09:13:07Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting a dataset using Macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting-a-dataset-using-Macro/m-p/191445#M48176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The macro starts ok, but if you always write to the same data set (raw_new) each time you invoke the macro function &lt;SPAN style="font-family: 'courier new', courier;"&gt;%dt&lt;/SPAN&gt; then raw_new will be overwritten each time, the last time being with orange_2 data which might be why you're not seeing apple_1 data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try something like (untested):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%macro dt (value);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; data raw_new_temp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set raw;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where index(score, "&amp;amp;value");&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em; font-family: 'courier new', courier;"&gt;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; proc append base=raw_new&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data=raw_new_temp&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; force;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; run;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%mend dt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%dt(apple_1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%dt(orange_2);&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above code creates a temporary data set then appends it to raw_new.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Amir - corrected reference to raw_new.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Apr 2014 11:25:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting-a-dataset-using-Macro/m-p/191445#M48176</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2014-04-24T11:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting a dataset using Macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting-a-dataset-using-Macro/m-p/191446#M48177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That worked, Amit! Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Apr 2014 15:18:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting-a-dataset-using-Macro/m-p/191446#M48177</guid>
      <dc:creator>Pujasharma</dc:creator>
      <dc:date>2014-04-24T15:18:30Z</dc:date>
    </item>
  </channel>
</rss>

