<?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: Calculating a new column in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-a-new-column/m-p/458352#M29522</link>
    <description>&lt;P&gt;You can sort the data by group and then use FIRST. to assign a value to that group.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input cust $;
datalines;
A
B
B
C
A
B
C
;
proc sort data=have;
by cust;
data want;
set have;
by cust;
if first.cust then ID+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 28 Apr 2018 14:12:25 GMT</pubDate>
    <dc:creator>SuryaKiran</dc:creator>
    <dc:date>2018-04-28T14:12:25Z</dc:date>
    <item>
      <title>Calculating a new column</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-a-new-column/m-p/458348#M29521</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table of&amp;nbsp;transaction data with a lot of different customer names in alphanumeric. Now i want to convert those names in a numeric variable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to have the following conversion:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Trans1. Customer A -&amp;gt; 1&lt;/P&gt;&lt;P&gt;Trans2. Customer B -&amp;gt; 2&amp;nbsp;&lt;/P&gt;&lt;P&gt;Trans3.&amp;nbsp;Customer C-&amp;gt; 3&lt;/P&gt;&lt;P&gt;Trans4. Customer A-&amp;gt; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is that possible? Can you help me pls.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks and regards,&lt;BR /&gt;Mariam&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Apr 2018 13:42:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-a-new-column/m-p/458348#M29521</guid>
      <dc:creator>Mairam2345</dc:creator>
      <dc:date>2018-04-28T13:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating a new column</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-a-new-column/m-p/458352#M29522</link>
      <description>&lt;P&gt;You can sort the data by group and then use FIRST. to assign a value to that group.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input cust $;
datalines;
A
B
B
C
A
B
C
;
proc sort data=have;
by cust;
data want;
set have;
by cust;
if first.cust then ID+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 28 Apr 2018 14:12:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-a-new-column/m-p/458352#M29522</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-04-28T14:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating a new column</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-a-new-column/m-p/458628#M29533</link>
      <description>&lt;P&gt;Hi- If i understood correctly, you have specific values that needs to be changed to numeric .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the below code, you are checking for specific values for names and assigning new_val variable to numeric values as you mentioned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data need;
set have;

if name in("Trans1. Customer A" ,"Trans4. Customer A") then new_val = 1;

else if name in("Trans2. Customer B"0 then new_val = 2;

else if name in("Trans3. Customer C"0 then new_val = 3;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Apr 2018 13:28:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-a-new-column/m-p/458628#M29533</guid>
      <dc:creator>mnjtrana</dc:creator>
      <dc:date>2018-04-30T13:28:21Z</dc:date>
    </item>
  </channel>
</rss>

