<?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: How to select correct records from dataset? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-correct-records-from-dataset/m-p/446620#M112090</link>
    <description>&lt;P&gt;Is your sample an exact representative of your &lt;EM&gt;&lt;STRONG&gt;real&lt;/STRONG&gt;&lt;/EM&gt;?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input adverse $ 1-12 count1;
cards;
Diarhoea [1] 170
Diarhoea      100
Rash [2]       174 
Rash            145 
Nausea [3]   123 
Nausea         67
Anemia [4]    156 
Cardiac         167 
Fatigue          174 
;
run;

data grp;
set test;
grp=scan(adverse,1);
run;
data want;
set grp;
by grp notsorted;
if (first.grp and last.grp) or (first.grp and countw(adverse)&amp;gt;1);
drop grp;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 18 Mar 2018 21:25:47 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-03-18T21:25:47Z</dc:date>
    <item>
      <title>How to select correct records from dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-correct-records-from-dataset/m-p/446615#M112081</link>
      <description>&lt;P&gt;Hi guys,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need some help. Below I prepared example dataset with few records&amp;nbsp;of clinical trial data. I need to to write smart code to select correct records. Every record with number in brackets [ ] are called &lt;STRONG&gt;cluster terms,&lt;/STRONG&gt; records without [ ] are called &lt;STRONG&gt;preffered terms.&amp;nbsp;&lt;/STRONG&gt; For example Diarhoea [1] will be &lt;STRONG&gt;cluster term&lt;/STRONG&gt; while Diarhoea will be &lt;STRONG&gt;preffered term&lt;/STRONG&gt;. If both recrods are presented &lt;STRONG&gt;then only cluster term must be displayed&lt;/STRONG&gt;. If only preffered term is presented then I want to keep this record in dataset. So for example in below data we can see Diarhoea [1] cluster and Diarhoea preffered term so I want to keep only Diarhoea [1] cluster and remove Diarhoea preffered term from dataset.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;input adverse $ 1-12 count1;&lt;BR /&gt;cards;&lt;BR /&gt;Diarhoea [1] 170&lt;BR /&gt;Diarhoea&amp;nbsp; &amp;nbsp; &amp;nbsp; 100&lt;BR /&gt;Rash [2]&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;174&amp;nbsp;&lt;BR /&gt;Rash&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 145&amp;nbsp;&lt;BR /&gt;Nausea [3]&amp;nbsp; &amp;nbsp;123&amp;nbsp;&lt;BR /&gt;Nausea&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;67&lt;BR /&gt;Anemia [4]&amp;nbsp; &amp;nbsp; 156&amp;nbsp;&lt;BR /&gt;Cardiac&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;167&amp;nbsp;&lt;BR /&gt;Fatigue&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 174&amp;nbsp;&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data after processing should look like :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Diarhoea [1] 170&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Rash [2]&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;174&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Nausea [3]&amp;nbsp; &amp;nbsp;123&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Anemia [4]&amp;nbsp; &amp;nbsp; 156&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cardiac&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;167&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Fatigue&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;174&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you in advance for help !&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Mar 2018 20:38:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-correct-records-from-dataset/m-p/446615#M112081</guid>
      <dc:creator>Pysiek</dc:creator>
      <dc:date>2018-03-18T20:38:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to select correct records from dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-correct-records-from-dataset/m-p/446620#M112090</link>
      <description>&lt;P&gt;Is your sample an exact representative of your &lt;EM&gt;&lt;STRONG&gt;real&lt;/STRONG&gt;&lt;/EM&gt;?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input adverse $ 1-12 count1;
cards;
Diarhoea [1] 170
Diarhoea      100
Rash [2]       174 
Rash            145 
Nausea [3]   123 
Nausea         67
Anemia [4]    156 
Cardiac         167 
Fatigue          174 
;
run;

data grp;
set test;
grp=scan(adverse,1);
run;
data want;
set grp;
by grp notsorted;
if (first.grp and last.grp) or (first.grp and countw(adverse)&amp;gt;1);
drop grp;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Mar 2018 21:25:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-correct-records-from-dataset/m-p/446620#M112090</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-03-18T21:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to select correct records from dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-correct-records-from-dataset/m-p/446621#M112091</link>
      <description>&lt;P&gt;&lt;FONT color="#000000"&gt;Hi Novinosrin,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Your code is working fine, but sometimes there are cases when I have few preffered terms starting with same word like :&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;A href="http://bioportal.bioontology.org/ontologies/MEDDRA/?p=classes&amp;amp;conceptid=http%3A%2F%2Fpurl.bioontology.org%2Fontology%2FMEDDRA%2F10037867" target="_blank"&gt;&lt;SPAN class="prefLabel"&gt;Rash macular&lt;/SPAN&gt;&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;A href="http://bioportal.bioontology.org/ontologies/MEDDRA/?p=classes&amp;amp;conceptid=http%3A%2F%2Fpurl.bioontology.org%2Fontology%2FMEDDRA%2F10037868" target="_blank"&gt;&lt;SPAN class="prefLabel"&gt;Rash maculo-papular&lt;/SPAN&gt;&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;A href="http://bioportal.bioontology.org/ontologies/MEDDRA/?p=classes&amp;amp;conceptid=http%3A%2F%2Fpurl.bioontology.org%2Fontology%2FMEDDRA%2F10050004" target="_blank"&gt;&lt;SPAN class="prefLabel"&gt;Rash maculovesicular&lt;/SPAN&gt;&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;A href="http://bioportal.bioontology.org/ontologies/MEDDRA/?p=classes&amp;amp;conceptid=http%3A%2F%2Fpurl.bioontology.org%2Fontology%2FMEDDRA%2F10037870" target="_blank"&gt;&lt;SPAN class="prefLabel"&gt;Rash morbilliform&lt;/SPAN&gt;&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;A href="http://bioportal.bioontology.org/ontologies/MEDDRA/?p=classes&amp;amp;conceptid=http%3A%2F%2Fpurl.bioontology.org%2Fontology%2FMEDDRA%2F10037871" target="_blank"&gt;&lt;SPAN class="prefLabel"&gt;Rash neonatal&lt;/SPAN&gt;&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;A href="http://bioportal.bioontology.org/ontologies/MEDDRA/?p=classes&amp;amp;conceptid=http%3A%2F%2Fpurl.bioontology.org%2Fontology%2FMEDDRA%2F10037876" target="_blank"&gt;&lt;SPAN class="prefLabel"&gt;Rash papular&lt;/SPAN&gt;&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;A href="http://bioportal.bioontology.org/ontologies/MEDDRA/?p=classes&amp;amp;conceptid=http%3A%2F%2Fpurl.bioontology.org%2Fontology%2FMEDDRA%2F10057984" target="_blank"&gt;&lt;SPAN class="prefLabel"&gt;Rash rubelliform&lt;/SPAN&gt;&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;A href="http://bioportal.bioontology.org/ontologies/MEDDRA/?p=classes&amp;amp;conceptid=http%3A%2F%2Fpurl.bioontology.org%2Fontology%2FMEDDRA%2F10037890" target="_blank"&gt;&lt;SPAN class="prefLabel"&gt;Rash scarlatiniform&lt;/SPAN&gt;&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN class="prefLabel"&gt;&lt;A href="http://bioportal.bioontology.org/ontologies/MEDDRA/?p=classes&amp;amp;conceptid=http%3A%2F%2Fpurl.bioontology.org%2Fontology%2FMEDDRA%2F10037898" target="_blank"&gt;Rash vesicular&lt;/A&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Updated data :&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;data test;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;input adverse $ 1-12 count1;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;cards;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;Diarhoea [1] 170&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;Diarhoea 100&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;Rash [2] 174 &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;Rash 145 &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;Rash macular 100&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN class="prefLabel"&gt;&lt;A href="http://bioportal.bioontology.org/ontologies/MEDDRA/?p=classes&amp;amp;conceptid=http%3A%2F%2Fpurl.bioontology.org%2Fontology%2FMEDDRA%2F10037876" target="_blank"&gt;Rash papular&lt;/A&gt;&amp;nbsp;89&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;Nausea [3] 123 &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;Nausea 67&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;Anemia [4] 156 &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;Cardiac 167 &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;Fatigue 174 &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;So in this scenario "Rash macular" and "Rash papular" should stay in dataset. Only "Rash" should be removed.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Mar 2018 21:43:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-correct-records-from-dataset/m-p/446621#M112091</guid>
      <dc:creator>Pysiek</dc:creator>
      <dc:date>2018-03-18T21:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to select correct records from dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-correct-records-from-dataset/m-p/446632#M112097</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input adverse  &amp;amp; $20. count1;
cards;
Diarhoea [1]  170
Diarhoea  100
Rash [2]  174 
Rash      145 
Rash macular  100
Rash papular  89
Nausea [3]  123 
Nausea   67
Anemia [4]   156 
Cardiac   167 
Fatigue   174 
;
run;

data grp;
set test;
grp=scan(adverse,1);
run;
data want;
set grp;
by grp notsorted;
if (first.grp and last.grp) or (first.grp and countw(adverse)&amp;gt;1) or (not first.grp and countw(adverse)&amp;gt;1);
drop grp;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Mar 2018 22:30:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-correct-records-from-dataset/m-p/446632#M112097</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-03-18T22:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to select correct records from dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-correct-records-from-dataset/m-p/446633#M112098</link>
      <description>&lt;P&gt;simplified further:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input adverse  &amp;amp; $20. count1;
cards;
Diarhoea [1]  170
Diarhoea  100
Rash [2]  174 
Rash      145 
Rash macular  100
Rash papular  89
Nausea [3]  123 
Nausea   67
Anemia [4]   156 
Cardiac   167 
Fatigue   174 
;
run;

data grp;
set test;
grp=scan(adverse,1);
run;

data want1;
set grp;
by grp notsorted;
if (first.grp and last.grp)  and countw(adverse)=1 or countw(adverse)&amp;gt;1;&lt;BR /&gt;drop grp;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Mar 2018 22:40:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-correct-records-from-dataset/m-p/446633#M112098</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-03-18T22:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to select correct records from dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-correct-records-from-dataset/m-p/446658#M112110</link>
      <description>&lt;P&gt;Another approach,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;&lt;BR /&gt;input adverse $ 1-12 count1;&lt;BR /&gt;cards;&lt;BR /&gt;Diarhoea [1] 170&lt;BR /&gt;Diarhoea&amp;nbsp; &amp;nbsp; &amp;nbsp; 100&lt;BR /&gt;Rash [2]&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;174&amp;nbsp;&lt;BR /&gt;Rash&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 145&amp;nbsp;&lt;BR /&gt;Nausea [3]&amp;nbsp; &amp;nbsp;123&amp;nbsp;&lt;BR /&gt;Nausea&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;67&lt;BR /&gt;Anemia [4]&amp;nbsp; &amp;nbsp; 156&amp;nbsp;&lt;BR /&gt;Cardiac&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;167&amp;nbsp;&lt;BR /&gt;Fatigue&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 174&amp;nbsp;&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data want;
set test;
by adverse notsorted;
adverse1=scan(adverse,1,'[ ');
run;

data want2;
length adverse2 $200;
set want;
retain adverse2;
by adverse1 notsorted;
if first.adverse1 then adverse2=adverse;
run;

data want3(rename=(adverse2=adverse));
set want2;
by adverse2 notsorted;
if last.adverse2;
drop adverse1 adverse;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Mar 2018 01:05:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-correct-records-from-dataset/m-p/446658#M112110</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2018-03-19T01:05:46Z</dc:date>
    </item>
  </channel>
</rss>

