<?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: Finding a match for one value in another column then pulling the value to the right of it. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Finding-a-match-for-one-value-in-another-column-then-pulling-the/m-p/330578#M62619</link>
    <description>&lt;P&gt;I think it will help to provide some example input data and the desired result. Best is to post example code as a datastep so we know exactly what things look like. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn a SAS data set into data step code that can be pasted here as text in a code box opened with the {i} icon or attached as a text file.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Feb 2017 18:56:20 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-02-07T18:56:20Z</dc:date>
    <item>
      <title>Finding a match for one value in another column then pulling the value to the right of it.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Finding-a-match-for-one-value-in-another-column-then-pulling-the/m-p/330575#M62618</link>
      <description>&lt;P&gt;I am pretty the solution to this is proc sql but I haven't touched that procedure very much so I need help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have recruitment data that has 6 columns: Particiapant ID, ID of 1st person recruited, ID of 2nd person recruited, ID of 3rd person recruited, ID of 4th person recruited, ID of 5th person recruited. I need a column that has the recuriter of the participant. I need to take the participant ID in the first column and search through the 5 columns of the IDs for the recruited among all of the observations. When I find a match, I need to pull the corresponding participant ID and throw it into a new variable for the original observation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyone know of a relatively simple way to execute this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 18:49:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Finding-a-match-for-one-value-in-another-column-then-pulling-the/m-p/330575#M62618</guid>
      <dc:creator>sasuser31</dc:creator>
      <dc:date>2017-02-07T18:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a match for one value in another column then pulling the value to the right of it.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Finding-a-match-for-one-value-in-another-column-then-pulling-the/m-p/330578#M62619</link>
      <description>&lt;P&gt;I think it will help to provide some example input data and the desired result. Best is to post example code as a datastep so we know exactly what things look like. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn a SAS data set into data step code that can be pasted here as text in a code box opened with the {i} icon or attached as a text file.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 18:56:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Finding-a-match-for-one-value-in-another-column-then-pulling-the/m-p/330578#M62619</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-02-07T18:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a match for one value in another column then pulling the value to the right of it.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Finding-a-match-for-one-value-in-another-column-then-pulling-the/m-p/330587#M62621</link>
      <description>&lt;P&gt;I would start by reformatting your data into just two columns, along these lines:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;if Participant_ID &amp;gt; ' ';&lt;/P&gt;
&lt;P&gt;Recruiter = Participant_ID;&lt;/P&gt;
&lt;P&gt;if ID1 &amp;gt; ' ' then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; Participant_ID = ID1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;if ID2 &amp;gt; ' ' then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; Participant_ID = ID2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;if ID5 &amp;gt; ' ' then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; Participant_ID = ID5;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;keep Recruiter Participant_ID;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This gives you a data set that you can compare with your current data.&amp;nbsp; match on the Participant_ID to determine the Recruiter (doesn't matter if&amp;nbsp; you use SQL or a MERGE in SAS ... whatever you are comfortable doing).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is entirely possible that your data is not clean and that you have to work with it first.&amp;nbsp; For example, it is conceivable that more than one Participant claims to have recruited the same person.&amp;nbsp; You may need a process that selects who to use as the Recruiter when there is a conflict.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 19:43:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Finding-a-match-for-one-value-in-another-column-then-pulling-the/m-p/330587#M62621</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-02-07T19:43:10Z</dc:date>
    </item>
  </channel>
</rss>

