<?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: Not getting correct output during match merging in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Not-getting-correct-output-during-match-merging/m-p/413351#M101148</link>
    <description>&lt;P&gt;Thanks in looking into my concern.&lt;/P&gt;&lt;P&gt;I would like to know whether the below code is correct. it means whether I should use alias p.country or only country to get correct result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;upper(strip(c.country)) in (select upper(strip(p.country)) from parent)&lt;/PRE&gt;&lt;P&gt;But I am not getting output while testing the same in my project.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any alternative approach to retreive the data in &amp;nbsp;a more faster way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 14 Nov 2017 15:01:43 GMT</pubDate>
    <dc:creator>Sauda</dc:creator>
    <dc:date>2017-11-14T15:01:43Z</dc:date>
    <item>
      <title>Not getting correct output during match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Not-getting-correct-output-during-match-merging/m-p/413345#M101144</link>
      <description>&lt;P&gt;Hi Expert,&lt;/P&gt;&lt;P&gt;I am not getting correct output when testing this code in huge data. The programming is running with zero output.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want all records from child sheet when country, product and dosage matches between two datasets.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; or country-product matches between two dataset only when dosage values is null for child dataset&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Product data column should be considered as pattern matching.&lt;/P&gt;&lt;P&gt;Can you please help me where I have done the mistake or is there any altenative approach to retrieve data in a faster way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Child;
input pid country $ product &amp;amp; $25. dosage $;
cards;
101 France Atorvastatin          Oral
102 France PaRacetamol            .
103 Russia Nimusulide injection  sc
104 China DIovan                 Tablet
105 Japan Gelusil                Tablet
106 India Codeine                Tablet 
;
run;

data Parent;
input country $ product &amp;amp; $25. dosage $;
cards;
JapaN Atorvastatin calcium 		Oral
China Atorvastatin 				Oral   
France Atorvastatin calcium 	Oral   
Russia Paracetamol 				Oral   
India Paracetamol 				Oral   
France Paracetamol 				Oral   
RusSia Nimusulide 				sc   
China diovan Syrup   			.
China diovan 					.
China Gelusil 					.
india Codeine 					.
Japan Gelusil Tablet			.
;
run;

proc sql;
create table match_country_prod_dos as
			select c.* 
				from child c, parent p
				where upper(compress(c.country)) in (select upper(compress(p.country)) from parent)
				and (upper(compress(c.product)) like '%' || upper(compress(p.product)) || '%'  or upper(compress(p.product)) like '%' ||upper(compress(c.product))|| '%')
				and upper(compress(c.dosage)) in (select upper(compress(p.dosage)) from parent);
quit;
 

proc sql;
create table match_country_prod_dosagenull as
			select c.* 
				from child c, parent p
				where c.dosage is null
				and upper(compress(c.country)) in (select upper(compress(p.country)) from parent)
				and (upper(compress(c.product)) like '%' || upper(compress(p.product)) || '%'  or upper(compress(p.product)) like '%' ||upper(compress(c.product))|| '%')
				;
quit;
 

data final;
set  match_country_prod_dos match_country_prod_dosagenull;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 14:50:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Not-getting-correct-output-during-match-merging/m-p/413345#M101144</guid>
      <dc:creator>Sauda</dc:creator>
      <dc:date>2017-11-14T14:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: Not getting correct output during match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Not-getting-correct-output-during-match-merging/m-p/413348#M101146</link>
      <description>&lt;P&gt;Compress is not the function you want to use.&amp;nbsp; You want to remove blanks from start and end, compress will trim out all spaces.&amp;nbsp; If you modify your code to:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table match_country_prod_dos as&lt;BR /&gt;  select c.* 
  from child c, parent p
  where upper(strip(c.country)) in (select upper(strip(p.country)) from parent)&lt;BR /&gt;    and (upper(strip(c.product)) like cats('%',upper(p.product),'%')  or upper(strip(p.product)) like cats('%',upper(c.product),'%'))
    and upper(strip(c.dosage)) in (select upper(strip(p.dosage)) from parent);
quit;
 &lt;/PRE&gt;
&lt;P&gt;Then you get results.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 14:56:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Not-getting-correct-output-during-match-merging/m-p/413348#M101146</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-14T14:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: Not getting correct output during match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Not-getting-correct-output-during-match-merging/m-p/413351#M101148</link>
      <description>&lt;P&gt;Thanks in looking into my concern.&lt;/P&gt;&lt;P&gt;I would like to know whether the below code is correct. it means whether I should use alias p.country or only country to get correct result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;upper(strip(c.country)) in (select upper(strip(p.country)) from parent)&lt;/PRE&gt;&lt;P&gt;But I am not getting output while testing the same in my project.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any alternative approach to retreive the data in &amp;nbsp;a more faster way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 15:01:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Not-getting-correct-output-during-match-merging/m-p/413351#M101148</guid>
      <dc:creator>Sauda</dc:creator>
      <dc:date>2017-11-14T15:01:43Z</dc:date>
    </item>
    <item>
      <title>Re: Not getting correct output during match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Not-getting-correct-output-during-match-merging/m-p/413363#M101149</link>
      <description>&lt;P&gt;You could try:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table match_country_prod_dos as&lt;BR /&gt;  select * 
  from   CHILD
  where  exists(select B.COUNTRY from PARENT B where upcase(strip(B.COUNTRY))=upcase(strip(COUNTRY)) and index(B.PRODUCT,PRODUCT)&amp;gt;0 and upcase(strip(B.DOSAGE))=upcase(strip(DOSAGE)));
quit;
 &lt;/PRE&gt;
&lt;P&gt;I would question why you have drug terms, which are not coded.&amp;nbsp; I do not see how you will merge these correctly.&amp;nbsp; Drugnames should be code with the appropriate coding dictionary WHODrug for instance.&amp;nbsp; This will give you the various coded levels for you to properly merge on.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 15:10:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Not-getting-correct-output-during-match-merging/m-p/413363#M101149</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-14T15:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: Not getting correct output during match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Not-getting-correct-output-during-match-merging/m-p/413418#M101175</link>
      <description>&lt;P&gt;The exists operator is not working and I am getting all rows from child dataset.&lt;/P&gt;&lt;P&gt;Actually the drug code is not available for this raw data for which I am comparing the product name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 17:35:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Not-getting-correct-output-during-match-merging/m-p/413418#M101175</guid>
      <dc:creator>Sauda</dc:creator>
      <dc:date>2017-11-14T17:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: Not getting correct output during match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Not-getting-correct-output-during-match-merging/m-p/413553#M101238</link>
      <description>Any help please</description>
      <pubDate>Wed, 15 Nov 2017 03:04:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Not-getting-correct-output-during-match-merging/m-p/413553#M101238</guid>
      <dc:creator>Sauda</dc:creator>
      <dc:date>2017-11-15T03:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Not getting correct output during match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Not-getting-correct-output-during-match-merging/m-p/413593#M101259</link>
      <description>&lt;P&gt;Add in the upcase(strip()) part and it should work:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table match_country_prod_dos as
  select A.*
  from   CHILD A
  where  exists(select distinct B.COUNTRY from PARENT B where (upcase(strip(B.COUNTRY))=upcase(strip(A.COUNTRY)) 
                  and upcase(strip(B.DOSAGE))=upcase(strip(A.DOSAGE)) and index(upcase(strip(B.PRODUCT)),upcase(strip(A.PRODUCT)))&amp;gt;0));
quit;&lt;/PRE&gt;
&lt;P&gt;However, I still advise you, if you are doing anything with this data, to first process it into a usable, standardised format - this will help you so much later on.&amp;nbsp; I.e. make sure the data is all formatted correctly - upcase country in both, apply standardised codes to the countries so different spellings no longer factor in.&amp;nbsp; Then merge on WHODrug or a drug library to get the various group levels to provide an acurate mergable variable.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 09:46:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Not-getting-correct-output-during-match-merging/m-p/413593#M101259</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-15T09:46:20Z</dc:date>
    </item>
  </channel>
</rss>

