<?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 assign new value to other value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/assign-new-value-to-other-value/m-p/456032#M115469</link>
    <description>&lt;P&gt;I tried to assign a new value to match with another value by group.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I use the code below, it came out all "AFC-WEST'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Conference = propcase(Team);&lt;/P&gt;&lt;P&gt;Retain Conference;&lt;/P&gt;&lt;P&gt;if Team = 'Ravens to Viking then Conference = 'AFC-NORTH';&lt;/P&gt;&lt;P&gt;else Conference = 'AFC-WEST;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result should look at below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Team&lt;/TD&gt;&lt;TD&gt;Conference&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Campbell&lt;/TD&gt;&lt;TD&gt;AFC-North&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;NorthRaleigh&lt;/TD&gt;&lt;TD&gt;AFC-North&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Batter&lt;/TD&gt;&lt;TD&gt;AFC-North&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Creek&lt;/TD&gt;&lt;TD&gt;AFC-North&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;South&lt;/TD&gt;&lt;TD&gt;AFC-West&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Miami&lt;/TD&gt;&lt;TD&gt;AFC-West&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Bellfort&lt;/TD&gt;&lt;TD&gt;AFC-West&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Viking&lt;/TD&gt;&lt;TD&gt;AFC-South&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Chief&lt;/TD&gt;&lt;TD&gt;AFC-South&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
    <pubDate>Fri, 20 Apr 2018 18:52:43 GMT</pubDate>
    <dc:creator>elsalam</dc:creator>
    <dc:date>2018-04-20T18:52:43Z</dc:date>
    <item>
      <title>assign new value to other value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assign-new-value-to-other-value/m-p/456032#M115469</link>
      <description>&lt;P&gt;I tried to assign a new value to match with another value by group.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I use the code below, it came out all "AFC-WEST'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Conference = propcase(Team);&lt;/P&gt;&lt;P&gt;Retain Conference;&lt;/P&gt;&lt;P&gt;if Team = 'Ravens to Viking then Conference = 'AFC-NORTH';&lt;/P&gt;&lt;P&gt;else Conference = 'AFC-WEST;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result should look at below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Team&lt;/TD&gt;&lt;TD&gt;Conference&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Campbell&lt;/TD&gt;&lt;TD&gt;AFC-North&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;NorthRaleigh&lt;/TD&gt;&lt;TD&gt;AFC-North&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Batter&lt;/TD&gt;&lt;TD&gt;AFC-North&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Creek&lt;/TD&gt;&lt;TD&gt;AFC-North&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;South&lt;/TD&gt;&lt;TD&gt;AFC-West&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Miami&lt;/TD&gt;&lt;TD&gt;AFC-West&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Bellfort&lt;/TD&gt;&lt;TD&gt;AFC-West&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Viking&lt;/TD&gt;&lt;TD&gt;AFC-South&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Chief&lt;/TD&gt;&lt;TD&gt;AFC-South&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 20 Apr 2018 18:52:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assign-new-value-to-other-value/m-p/456032#M115469</guid>
      <dc:creator>elsalam</dc:creator>
      <dc:date>2018-04-20T18:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: assign new value to other value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assign-new-value-to-other-value/m-p/456035#M115470</link>
      <description>&lt;P&gt;what do you mean by the if statement&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Conference = propcase(Team);&lt;/P&gt;&lt;P&gt;Retain Conference;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF6600"&gt;&lt;EM&gt;&lt;STRONG&gt;if Team = 'Ravens to Viking then Conference = 'AFC-NORTH';?/*for one, it is syntactically incorrect and 2. are you trying a range from Ravens--Viking*/&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;else Conference = 'AFC-WEST;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 18:56:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assign-new-value-to-other-value/m-p/456035#M115470</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-20T18:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: assign new value to other value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assign-new-value-to-other-value/m-p/456038#M115471</link>
      <description>&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Team&lt;/TD&gt;&lt;TD&gt;Conference&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Campbell&lt;/TD&gt;&lt;TD&gt;AFC-North&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;NorthRaleigh&lt;/TD&gt;&lt;TD&gt;AFC-North&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Batter&lt;/TD&gt;&lt;TD&gt;AFC-North&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Creek&lt;/TD&gt;&lt;TD&gt;AFC-North&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;South&lt;/TD&gt;&lt;TD&gt;AFC-West&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Miami&lt;/TD&gt;&lt;TD&gt;AFC-West&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Bellfort&lt;/TD&gt;&lt;TD&gt;AFC-West&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Viking&lt;/TD&gt;&lt;TD&gt;AFC-South&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Chief&lt;/TD&gt;&lt;TD&gt;AFC-South&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If team = 'Batter tp Creek' then Conference = 'AFC-NORTH';&lt;/P&gt;&lt;P&gt;I was trying to do the matching.&amp;nbsp; Batter and Creek are the value at Team column so it is Batter and CreeK.&amp;nbsp; SAS will assign AFC-NORTH to these value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really have no idea how to match.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 19:05:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assign-new-value-to-other-value/m-p/456038#M115471</guid>
      <dc:creator>elsalam</dc:creator>
      <dc:date>2018-04-20T19:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: assign new value to other value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assign-new-value-to-other-value/m-p/456039#M115472</link>
      <description>&lt;P&gt;When you have many character values to compare one way is to use the IN operator but you need to list every value you are looking for:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if team in ('Ravens' 'Otherteamname' 'Vikings') then ...&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 19:07:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assign-new-value-to-other-value/m-p/456039#M115472</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-04-20T19:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: assign new value to other value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assign-new-value-to-other-value/m-p/456040#M115473</link>
      <description>&lt;P&gt;aah ok,&amp;nbsp;&lt;/P&gt;&lt;P&gt;are you trying to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Conference = propcase(Team);&lt;/P&gt;&lt;P&gt;Retain Conference;&lt;/P&gt;&lt;P&gt;if Team =in ('Ravens' ,' Viking') then Conference = 'AFC-NORTH';&lt;/P&gt;&lt;P&gt;else Conference = 'AFC-WEST;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 19:07:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assign-new-value-to-other-value/m-p/456040#M115473</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-20T19:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: assign new value to other value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assign-new-value-to-other-value/m-p/456046#M115475</link>
      <description>&lt;P&gt;Yes, I changed it to&lt;/P&gt;&lt;P&gt;if team in ('Campbell','Batter') then Conference = 'AFC-NORTH';&lt;/P&gt;&lt;P&gt;else Conference = 'AFC-WEST';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It still the entire column are AFC-WEST.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And, if I have more than two value to be matched.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it a faster way to match them?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 19:15:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assign-new-value-to-other-value/m-p/456046#M115475</guid>
      <dc:creator>elsalam</dc:creator>
      <dc:date>2018-04-20T19:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: assign new value to other value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assign-new-value-to-other-value/m-p/456049#M115476</link>
      <description>&lt;P&gt;Try proc format, load your look up values in proc format and apply in a datastep&lt;/P&gt;&lt;P&gt;easy to maintain and edit&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 19:21:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assign-new-value-to-other-value/m-p/456049#M115476</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-20T19:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: assign new value to other value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assign-new-value-to-other-value/m-p/456055#M115478</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/202656"&gt;@elsalam&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Yes, I changed it to&lt;/P&gt;
&lt;P&gt;if team in ('Campbell','Batter') then Conference = 'AFC-NORTH';&lt;/P&gt;
&lt;P&gt;else Conference = 'AFC-WEST';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It still the entire column are AFC-WEST.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And, if I have more than two value to be matched.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it a faster way to match them?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Show the entire data step and any messages from log. Paste into a code box opened using the forum {I} icon to preserver formatting of code and any error or warning messages. It might also help to provide some actual values from you data as a data step. 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 an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that the comparison matches the entire field. So if the value has any leading blanks or other characters than "Campbell" the match will return false or if the data is not in the same case, "campbell" is not the same as "CAMPBELL" or "Campbell" or "cAmpbell"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The list of values used in the in comparison can be more than two, I just didn't feel like typing more.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 19:48:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assign-new-value-to-other-value/m-p/456055#M115478</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-04-20T19:48:39Z</dc:date>
    </item>
  </channel>
</rss>

