<?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: SAS Base- Loop through different dataset to check if some fields are the same and overwrite in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/SAS-Base-Loop-through-different-dataset-to-check-if-some-fields/m-p/503642#M854</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;first of all many thanks for the reply.&lt;/P&gt;&lt;P&gt;I think i am going to use the first approach of merging and sorting across the variables as the UNION SQL cannot distinguish which rowe (giving the criteria described) need to be kept or not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Luca&lt;/P&gt;</description>
    <pubDate>Fri, 12 Oct 2018 08:22:53 GMT</pubDate>
    <dc:creator>lucazanotti</dc:creator>
    <dc:date>2018-10-12T08:22:53Z</dc:date>
    <item>
      <title>SAS Base- Loop through different dataset to check if some fields are the same and overwrite</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-Base-Loop-through-different-dataset-to-check-if-some-fields/m-p/502481#M685</link>
      <description>&lt;P&gt;Dear suppport,&amp;nbsp;&lt;/P&gt;&lt;P&gt;i hope you can help me in this. I have the following datasets ("info" and "score").&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;id2&lt;/TD&gt;&lt;TD&gt;faculty&lt;/TD&gt;&lt;TD&gt;name&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;surname&lt;/TD&gt;&lt;TD&gt;course&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;x&l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t;joshua&lt;/TD&gt;&lt;TD&gt;yellow&lt;/TD&gt;&lt;TD&gt;math&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;z&lt;/TD&gt;&lt;TD&gt;joshua&lt;/TD&gt;&lt;TD&gt;yellow&lt;/TD&gt;&lt;TD&gt;english&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;z&lt;/TD&gt;&lt;TD&gt;joshua&lt;/TD&gt;&lt;TD&gt;yellow&lt;/TD&gt;&lt;TD&gt;art&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i would like to achieve is to insert some information in&amp;nbsp; "info" that recursively check based on some criteria if a specific entry on the "infor" is on score and if not append the new result in "infor". In detail it should check if Name and surname and id2 are in the score and only if the course is different append that line in "infor". My issue is that i have tried to do a data merge (and dropping one value) but unsuccessfull as the id field and faculty is wrong (not aligned with the infor or empty) .&lt;/P&gt;&lt;P&gt;The expected result should be like this:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;id2&lt;/TD&gt;&lt;TD&gt;faculty&lt;/TD&gt;&lt;TD&gt;name&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;surname&lt;/TD&gt;&lt;TD&gt;course&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;science&lt;/TD&gt;&lt;TD&gt;mark&lt;/TD&gt;&lt;TD&gt;red&lt;/TD&gt;&lt;TD&gt;math&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;y&lt;/TD&gt;&lt;TD&gt;science&lt;/TD&gt;&lt;TD&gt;lewis&lt;/TD&gt;&lt;TD&gt;green&lt;/TD&gt;&lt;TD&gt;math&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;z&lt;/TD&gt;&lt;TD&gt;eng&lt;/TD&gt;&lt;TD&gt;joshua&lt;/TD&gt;&lt;TD&gt;yellow&lt;/TD&gt;&lt;TD&gt;math&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;z&lt;/TD&gt;&lt;TD&gt;eng&lt;/TD&gt;&lt;TD&gt;joshua&lt;/TD&gt;&lt;TD&gt;yellow&lt;/TD&gt;&lt;TD&gt;english&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;science&lt;/TD&gt;&lt;TD&gt;mark&lt;/TD&gt;&lt;TD&gt;red&lt;/TD&gt;&lt;TD&gt;english&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;z&lt;/TD&gt;&lt;TD&gt;eng&lt;/TD&gt;&lt;TD&gt;joshua&lt;/TD&gt;&lt;TD&gt;yellow&lt;/TD&gt;&lt;TD&gt;art&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;with the last two observation inserted accordingly.&lt;/P&gt;&lt;P&gt;I wonder if is possible to loop through the dataset and check/compare (with if statements) and proceed to create the observation.&lt;/P&gt;&lt;P&gt;If you can post a link or guide me through into the right direction it would be amazing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;&lt;P&gt;Luca&lt;/P&gt;</description>
      <pubDate>Mon, 08 Oct 2018 18:57:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-Base-Loop-through-different-dataset-to-check-if-some-fields/m-p/502481#M685</guid>
      <dc:creator>lucazanotti</dc:creator>
      <dc:date>2018-10-08T18:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Base- Loop through different dataset to check if some fields are the same and overwrite</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-Base-Loop-through-different-dataset-to-check-if-some-fields/m-p/502492#M686</link>
      <description>&lt;P&gt;Sort and Merge can handle this with no problem.&amp;nbsp; If you ran into difficulties, you might have to add variables to the BY statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;by id id2 name surname course;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It could take all five variables to determine match vs. mismatch.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Oct 2018 19:23:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-Base-Loop-through-different-dataset-to-check-if-some-fields/m-p/502492#M686</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-10-08T19:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Base- Loop through different dataset to check if some fields are the same and overwrite</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-Base-Loop-through-different-dataset-to-check-if-some-fields/m-p/502511#M689</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sql;
create table want as
select distinct *
from
(select id	,id2	,	name ,	surname,	course from info
union 
select id	,id2	,	name ,	surname,	course from score);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Oct 2018 19:53:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-Base-Loop-through-different-dataset-to-check-if-some-fields/m-p/502511#M689</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-08T19:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Base- Loop through different dataset to check if some fields are the same and overwrite</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-Base-Loop-through-different-dataset-to-check-if-some-fields/m-p/503642#M854</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;first of all many thanks for the reply.&lt;/P&gt;&lt;P&gt;I think i am going to use the first approach of merging and sorting across the variables as the UNION SQL cannot distinguish which rowe (giving the criteria described) need to be kept or not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Luca&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2018 08:22:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-Base-Loop-through-different-dataset-to-check-if-some-fields/m-p/503642#M854</guid>
      <dc:creator>lucazanotti</dc:creator>
      <dc:date>2018-10-12T08:22:53Z</dc:date>
    </item>
  </channel>
</rss>

