<?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 find and match value in one column to another and return as new variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543318#M150180</link>
    <description>&lt;P&gt;If you want the program title, why use FD_CODE at all?&amp;nbsp; Why not just look up PROGRAM_TITLE based on PR_CODE?&lt;/P&gt;</description>
    <pubDate>Thu, 14 Mar 2019 20:56:31 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2019-03-14T20:56:31Z</dc:date>
    <item>
      <title>How to find and match value in one column to another and return as new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543300#M150175</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am using the sas enterprise guide&lt;/P&gt;&lt;P&gt;I have a dataset that contains a list of codes for first degree programs, all educational program titles and their codes ie. three columns; fd_code, program_title, pr_code&lt;/P&gt;&lt;P&gt;How do I look up fd_code from the pr_code column and create a new column with the corresponding program title&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;fd_code&lt;/TD&gt;&lt;TD&gt;program_title&lt;/TD&gt;&lt;TD&gt;pr_code&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2404&lt;/TD&gt;&lt;TD&gt;Aerospace Engineering&lt;/TD&gt;&lt;TD&gt;2401&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5001&lt;/TD&gt;&lt;TD&gt;Anthropology And Archeology&lt;/TD&gt;&lt;TD&gt;5502&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5001&lt;/TD&gt;&lt;TD&gt;Applied Mathematics&lt;/TD&gt;&lt;TD&gt;3701&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2403&lt;/TD&gt;&lt;TD&gt;Architectural Engineering&lt;/TD&gt;&lt;TD&gt;2403&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3701&lt;/TD&gt;&lt;TD&gt;Architecture&lt;/TD&gt;&lt;TD&gt;1401&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5223&lt;/TD&gt;&lt;TD&gt;Area Ethnic And Civilization Studies&lt;/TD&gt;&lt;TD&gt;1501&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 20:27:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543300#M150175</guid>
      <dc:creator>michokwu</dc:creator>
      <dc:date>2019-03-14T20:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to find and match value in one column to another and return as new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543318#M150180</link>
      <description>&lt;P&gt;If you want the program title, why use FD_CODE at all?&amp;nbsp; Why not just look up PROGRAM_TITLE based on PR_CODE?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 20:56:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543318#M150180</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-03-14T20:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to find and match value in one column to another and return as new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543319#M150181</link>
      <description>&lt;P&gt;I have individual A who has a first degree with just the fd_code given, I need to search the pr_code column to know the title of his/her first degree&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 21:00:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543319#M150181</guid>
      <dc:creator>michokwu</dc:creator>
      <dc:date>2019-03-14T21:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to find and match value in one column to another and return as new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543321#M150182</link>
      <description>&lt;P&gt;For that, you will have to show what you want.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So far, you have shown one source of data.&amp;nbsp; Clearly, you must have another source of data that you want to match with.&amp;nbsp; Give a brief example of what that other data source looks like, and what the result should be after matching.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 21:07:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543321#M150182</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-03-14T21:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to find and match value in one column to another and return as new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543323#M150183</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/255120"&gt;@michokwu&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have individual A who has a first degree with just the fd_code given, I need to search the pr_code column to know the title of his/her first degree&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In the sample data you've posted an fd_code doesn't map 1:1 to a pr_code. So if you've only got the fd_code how do you think you'd be able to determine the pr_code?&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;5001&lt;/TD&gt;
&lt;TD&gt;Anthropology And Archeology&lt;/TD&gt;
&lt;TD&gt;5502&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;5001&lt;/TD&gt;
&lt;TD&gt;Applied Mathematics&lt;/TD&gt;
&lt;TD&gt;3701&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;</description>
      <pubDate>Thu, 14 Mar 2019 21:10:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543323#M150183</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-03-14T21:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to find and match value in one column to another and return as new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543332#M150188</link>
      <description>&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just a column with serial_no. Its from a pubic data source, so the serial number column represents each individual&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 21:32:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543332#M150188</guid>
      <dc:creator>michokwu</dc:creator>
      <dc:date>2019-03-14T21:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to find and match value in one column to another and return as new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543333#M150189</link>
      <description>&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Serial_no&lt;/TD&gt;&lt;TD&gt;fd_code&lt;/TD&gt;&lt;TD&gt;program_title&lt;/TD&gt;&lt;TD&gt;pr_code&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2012000000150&lt;/TD&gt;&lt;TD&gt;2404&lt;/TD&gt;&lt;TD&gt;Aerospace Engineering&lt;/TD&gt;&lt;TD&gt;2401&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2012000000194&lt;/TD&gt;&lt;TD&gt;5001&lt;/TD&gt;&lt;TD&gt;Anthropology And Archeology&lt;/TD&gt;&lt;TD&gt;5502&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2012000000194&lt;/TD&gt;&lt;TD&gt;5001&lt;/TD&gt;&lt;TD&gt;Applied Mathematics&lt;/TD&gt;&lt;TD&gt;3701&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2012000000295&lt;/TD&gt;&lt;TD&gt;2403&lt;/TD&gt;&lt;TD&gt;Architectural Engineering&lt;/TD&gt;&lt;TD&gt;2403&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2012000000320&lt;/TD&gt;&lt;TD&gt;3701&lt;/TD&gt;&lt;TD&gt;Architecture&lt;/TD&gt;&lt;TD&gt;1401&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2012000000345&lt;/TD&gt;&lt;TD&gt;5223&lt;/TD&gt;&lt;TD&gt;Area Ethnic And Civilization Studies&lt;/TD&gt;&lt;TD&gt;1501&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 14 Mar 2019 21:35:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543333#M150189</guid>
      <dc:creator>michokwu</dc:creator>
      <dc:date>2019-03-14T21:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to find and match value in one column to another and return as new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543334#M150190</link>
      <description>&lt;P&gt;The pr_code maps to the program_title.&lt;/P&gt;&lt;P&gt;If I need to know the program title for individual A's first degree, I will need to take the fd_code as given, and search the pr_code to come up with the program title.&lt;/P&gt;&lt;P&gt;My thoughts.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 21:39:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543334#M150190</guid>
      <dc:creator>michokwu</dc:creator>
      <dc:date>2019-03-14T21:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to find and match value in one column to another and return as new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543335#M150191</link>
      <description>&lt;P&gt;If you have your pr_code and Program_title in a data set then easiest may be to make a custom format. Below I 1) create a data set using your example data, 2) add the variables that Proc Format requires to create a format, 3) use the data set created to create format using the CNTLIN option and 4) print the original have data set values of the PR_code using the format created.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
   infile datalines dlm='|';
   informat fd_code $4. program_title $50. pr_code $4.;
   input fd_code program_title pr_code ;
datalines;
2404|Aerospace Engineering|2401 
5001|Anthropology And Archeology|5502 
5001|Applied Mathematics|3701 
2403|Architectural Engineering|2403 
3701|Architecture|1401 
5223|Area Ethnic And Civilization Studies|1501 
;
run;

data temp;
   set have;
   fmtname='PROGRAM_TITLE';
   type='C';
   start=pr_code;
   label=program_title;
run;

proc format library=work cntlin=temp;
run;

Proc print data=have label;
   var pr_code;
   format pr_code $program_title.;
   label pr_code='Formatted PR_Code';
run;
&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Mar 2019 21:41:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543335#M150191</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-14T21:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to find and match value in one column to another and return as new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543342#M150196</link>
      <description>&lt;P&gt;Thanks. I received error message:&amp;nbsp;ERROR: You are trying to use the character format $PROGRAM with the numeric variable Pr_Code in data set WORK.PATH.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, the solution does not address how to find and match the value. I tried to assign the value of pr_code to program_title but could not.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I saw a similar but not exact discussion&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-assign-a-column-value-based-on-another-column/td-p/217728" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/How-to-assign-a-column-value-based-on-another-column/td-p/217728&lt;/A&gt; but still does not answer my question&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 22:30:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543342#M150196</guid>
      <dc:creator>michokwu</dc:creator>
      <dc:date>2019-03-14T22:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to find and match value in one column to another and return as new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543350#M150197</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/255120"&gt;@michokwu&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks. I received error message:&amp;nbsp;ERROR: You are trying to use the character format $PROGRAM with the numeric variable Pr_Code in data set WORK.PATH.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, the solution does not address how to find and match the value. I tried to assign the value of pr_code to program_title but could not.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I saw a similar but not exact discussion&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-assign-a-column-value-based-on-another-column/td-p/217728" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/How-to-assign-a-column-value-based-on-another-column/td-p/217728&lt;/A&gt; but still does not answer my question&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since you did not provide data in the form&amp;nbsp;of a data step I have to &lt;STRONG&gt;guess&lt;/STRONG&gt; whether values like pr_code are numeric or character. Most things named "code", like Zipcode, are identifiers and generally are not used for numeric calculation and hence are character.&lt;/P&gt;
&lt;P&gt;Remove the quotes around the pr_code values in the format, remove the $ from both the Proc format definition and the proc print.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 23:03:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-match-value-in-one-column-to-another-and-return/m-p/543350#M150197</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-14T23:03:28Z</dc:date>
    </item>
  </channel>
</rss>

