<?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 Based on Drug Name Using the Find Function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Based-on-Drug-Name-Using-the-Find-Function/m-p/430153#M106320</link>
    <description>&lt;P&gt;Do you need new datasets?&lt;/P&gt;
&lt;P&gt;How about this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
 proc print data=input; 
  where find(drug,'Sertraline','i') ; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jan 2018 20:30:13 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2018-01-23T20:30:13Z</dc:date>
    <item>
      <title>Subset Data Based on Drug Name Using the Find Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Based-on-Drug-Name-Using-the-Find-Function/m-p/430139#M106309</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am relatively new to SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Task: I need to subset my data based on "drug name," since I am studying a particular class. To accomplish this, I need to search the names and export all observations to a new data set.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am able to use the find function to subset the data using the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data new;&lt;BR /&gt;set input;&lt;BR /&gt;if find(drug,'Fluoxetine','i') ge 1;&lt;BR /&gt;run;&lt;BR /&gt;proc print data=new&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data new1;&lt;BR /&gt;set input;&lt;BR /&gt;if find(drug,'Sertraline','i') ge 1;&lt;BR /&gt;run;&lt;BR /&gt;proc print data=new1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I would need to do this for each drug name and then merge the data sets based on subject ID.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What method would you suggest to efficiently accomplish this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 19:57:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Based-on-Drug-Name-Using-the-Find-Function/m-p/430139#M106309</guid>
      <dc:creator>mglogan</dc:creator>
      <dc:date>2018-01-23T19:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: Subset Data Based on Drug Name Using the Find Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Based-on-Drug-Name-Using-the-Find-Function/m-p/430141#M106310</link>
      <description>&lt;P&gt;Rather than multiple data pulls, do it all in one pull using a temporary array. Assuming you have 5 drugs you're searching for something like the following may work (untested, I suspect my array definition is incorrect, you may need a _character_ to specify it's a character array).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;

set input;

array _drugs(5) _temporary_ ('Fluoxetine', 'Sertaline', 'random1', 'random2', 'random3');

flag=0;
do i=1 to dim(_drugs);

if find(drug, _drugs(i), 'i') &amp;gt; 0 then do;
flag=1;
leave;
end;

end;&lt;BR /&gt;&lt;BR /&gt;if flag=1 then output; *keeps only records of interest;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Jan 2018 20:01:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Based-on-Drug-Name-Using-the-Find-Function/m-p/430141#M106310</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-23T20:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: Subset Data Based on Drug Name Using the Find Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Based-on-Drug-Name-Using-the-Find-Function/m-p/430153#M106320</link>
      <description>&lt;P&gt;Do you need new datasets?&lt;/P&gt;
&lt;P&gt;How about this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
 proc print data=input; 
  where find(drug,'Sertraline','i') ; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 20:30:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Based-on-Drug-Name-Using-the-Find-Function/m-p/430153#M106320</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-01-23T20:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: Subset Data Based on Drug Name Using the Find Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Based-on-Drug-Name-Using-the-Find-Function/m-p/430252#M106353</link>
      <description>Thank you! This worked with few adjustments.</description>
      <pubDate>Wed, 24 Jan 2018 02:12:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Based-on-Drug-Name-Using-the-Find-Function/m-p/430252#M106353</guid>
      <dc:creator>mglogan</dc:creator>
      <dc:date>2018-01-24T02:12:24Z</dc:date>
    </item>
  </channel>
</rss>

