<?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: Create a new column based on specific sitution in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-column-based-on-specific-sitution/m-p/459424#M70236</link>
    <description>&lt;P&gt;This is a pretty straight look up or join/merge on the names. Or a format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which approach are you looking to use, and what have you tried so far?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a template dataset which have 500 obs.&amp;nbsp; The sample dataset is shown below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data template; 
      infile datalines dlm='|'; 
  input Product : $20. Class : $50.; 
datalines;                  
BENADRYL |  ETHANOLAMINE |   
UNISOM TABLETS |  ETHANOLAMINE |   
PHENERGAN |  PHENOTHIAZINE |  
PROMETHAZINE |  PHENOTHIAZINE | 
KEFLEX |  CEPH/FIRST GENERATION |   
NOVOCAINE |  LOCAL ANESTHETICS |   
PREDNISONE |  ADRENALS |  
PULMICORT |  ADRENALS |  
RHINOCORT |  ADRENALS | 
; 

Proc sort; by class; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I have a dataset with 10K obs,&amp;nbsp; below is only&amp;nbsp; my sample dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
  format ShipDate mmddyy10.;
  infile datalines dlm='|'; 
  input ID $10. Product : $20.  shipdate : mmddyy10.; 
datalines;                  
100012556 | BENADRYL |  01/08/2010 |   
600012956 | UNISOM TABLETS |  09/02/2017 |   
500012586 | PHENERGAN |  06/24/2006 |  
500052586 | PROMETHAZINE |  05/03/2007 | 
200052576 | KEFLEX |  07/31/2003 |   
600052577 | NOVOCAINE |  03/25/2001 |   
900052578 | PREDNISONE |  06/17/2018 |  
800012578 | PULMICORT |  09/12/2002 |  
600012878 | RHINOCORT |  12/14/2016 | 
; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I would like to create a new&amp;nbsp;"Class" column in "Have" dataset based on the "Template" dataset condition.&amp;nbsp;&amp;nbsp; Below is the result I want.&amp;nbsp;&amp;nbsp; Please let me know how to approach this, thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want; 
	format ShipDate mmddyy10.;
    infile datalines dlm='|'; 
    input ID $10. Product : $20. Class : $50. shipdate : mmddyy10.; 
datalines;                  
100012556 | BENADRYL |  ETHANOLAMINE |  01/08/2010 
600012956 | UNISOM TABLETS |  ETHANOLAMINE | 09/02/2017  
500012586 | PHENERGAN |  PHENOTHIAZINE | 06/24/2006 
500052586 | PROMETHAZINE |  PHENOTHIAZINE | 05/03/2007
200052576 | KEFLEX |  CEPH/FIRST GENERATION | 07/31/2003  
600052577 | NOVOCAINE |  LOCAL ANESTHETICS |  03/25/2001 
900052578 | PREDNISONE |  ADRENALS | 06/17/2018 
800012578 | PULMICORT |  ADRENALS |  09/12/2002
600012878 | RHINOCORT |  ADRENALS | 12/14/2016
; 

Proc sort; by class; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 02 May 2018 17:23:55 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-05-02T17:23:55Z</dc:date>
    <item>
      <title>Create a new column based on specific sitution</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-column-based-on-specific-sitution/m-p/459415#M70234</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a template dataset which have 500 obs.&amp;nbsp; The sample dataset is shown below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data template; 
      infile datalines dlm='|'; 
  input Product : $20. Class : $50.; 
datalines;                  
BENADRYL |  ETHANOLAMINE |   
UNISOM TABLETS |  ETHANOLAMINE |   
PHENERGAN |  PHENOTHIAZINE |  
PROMETHAZINE |  PHENOTHIAZINE | 
KEFLEX |  CEPH/FIRST GENERATION |   
NOVOCAINE |  LOCAL ANESTHETICS |   
PREDNISONE |  ADRENALS |  
PULMICORT |  ADRENALS |  
RHINOCORT |  ADRENALS | 
; 

Proc sort; by class; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I have a dataset with 10K obs,&amp;nbsp; below is only&amp;nbsp; my sample dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
  format ShipDate mmddyy10.;
  infile datalines dlm='|'; 
  input ID $10. Product : $20.  shipdate : mmddyy10.; 
datalines;                  
100012556 | BENADRYL |  01/08/2010 |   
600012956 | UNISOM TABLETS |  09/02/2017 |   
500012586 | PHENERGAN |  06/24/2006 |  
500052586 | PROMETHAZINE |  05/03/2007 | 
200052576 | KEFLEX |  07/31/2003 |   
600052577 | NOVOCAINE |  03/25/2001 |   
900052578 | PREDNISONE |  06/17/2018 |  
800012578 | PULMICORT |  09/12/2002 |  
600012878 | RHINOCORT |  12/14/2016 | 
; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I would like to create a new&amp;nbsp;"Class" column in "Have" dataset based on the "Template" dataset condition.&amp;nbsp;&amp;nbsp; Below is the result I want.&amp;nbsp;&amp;nbsp; Please let me know how to approach this, thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want; 
	format ShipDate mmddyy10.;
    infile datalines dlm='|'; 
    input ID $10. Product : $20. Class : $50. shipdate : mmddyy10.; 
datalines;                  
100012556 | BENADRYL |  ETHANOLAMINE |  01/08/2010 
600012956 | UNISOM TABLETS |  ETHANOLAMINE | 09/02/2017  
500012586 | PHENERGAN |  PHENOTHIAZINE | 06/24/2006 
500052586 | PROMETHAZINE |  PHENOTHIAZINE | 05/03/2007
200052576 | KEFLEX |  CEPH/FIRST GENERATION | 07/31/2003  
600052577 | NOVOCAINE |  LOCAL ANESTHETICS |  03/25/2001 
900052578 | PREDNISONE |  ADRENALS | 06/17/2018 
800012578 | PULMICORT |  ADRENALS |  09/12/2002
600012878 | RHINOCORT |  ADRENALS | 12/14/2016
; 

Proc sort; by class; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 16:57:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-column-based-on-specific-sitution/m-p/459415#M70234</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2018-05-02T16:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new column based on specific sitution</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-column-based-on-specific-sitution/m-p/459423#M70235</link>
      <description>&lt;P&gt;SAS has many ways of combining tables, based on finding a match.&amp;nbsp; Which are you most comfortable with?&amp;nbsp; DATA step MERGE?&amp;nbsp; SQL join?&amp;nbsp; Formats?&amp;nbsp; Hashing?&amp;nbsp; Pick an approach you understand, so you can build on what you already know.&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 17:22:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-column-based-on-specific-sitution/m-p/459423#M70235</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-05-02T17:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new column based on specific sitution</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-column-based-on-specific-sitution/m-p/459424#M70236</link>
      <description>&lt;P&gt;This is a pretty straight look up or join/merge on the names. Or a format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which approach are you looking to use, and what have you tried so far?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a template dataset which have 500 obs.&amp;nbsp; The sample dataset is shown below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data template; 
      infile datalines dlm='|'; 
  input Product : $20. Class : $50.; 
datalines;                  
BENADRYL |  ETHANOLAMINE |   
UNISOM TABLETS |  ETHANOLAMINE |   
PHENERGAN |  PHENOTHIAZINE |  
PROMETHAZINE |  PHENOTHIAZINE | 
KEFLEX |  CEPH/FIRST GENERATION |   
NOVOCAINE |  LOCAL ANESTHETICS |   
PREDNISONE |  ADRENALS |  
PULMICORT |  ADRENALS |  
RHINOCORT |  ADRENALS | 
; 

Proc sort; by class; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I have a dataset with 10K obs,&amp;nbsp; below is only&amp;nbsp; my sample dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
  format ShipDate mmddyy10.;
  infile datalines dlm='|'; 
  input ID $10. Product : $20.  shipdate : mmddyy10.; 
datalines;                  
100012556 | BENADRYL |  01/08/2010 |   
600012956 | UNISOM TABLETS |  09/02/2017 |   
500012586 | PHENERGAN |  06/24/2006 |  
500052586 | PROMETHAZINE |  05/03/2007 | 
200052576 | KEFLEX |  07/31/2003 |   
600052577 | NOVOCAINE |  03/25/2001 |   
900052578 | PREDNISONE |  06/17/2018 |  
800012578 | PULMICORT |  09/12/2002 |  
600012878 | RHINOCORT |  12/14/2016 | 
; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I would like to create a new&amp;nbsp;"Class" column in "Have" dataset based on the "Template" dataset condition.&amp;nbsp;&amp;nbsp; Below is the result I want.&amp;nbsp;&amp;nbsp; Please let me know how to approach this, thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want; 
	format ShipDate mmddyy10.;
    infile datalines dlm='|'; 
    input ID $10. Product : $20. Class : $50. shipdate : mmddyy10.; 
datalines;                  
100012556 | BENADRYL |  ETHANOLAMINE |  01/08/2010 
600012956 | UNISOM TABLETS |  ETHANOLAMINE | 09/02/2017  
500012586 | PHENERGAN |  PHENOTHIAZINE | 06/24/2006 
500052586 | PROMETHAZINE |  PHENOTHIAZINE | 05/03/2007
200052576 | KEFLEX |  CEPH/FIRST GENERATION | 07/31/2003  
600052577 | NOVOCAINE |  LOCAL ANESTHETICS |  03/25/2001 
900052578 | PREDNISONE |  ADRENALS | 06/17/2018 
800012578 | PULMICORT |  ADRENALS |  09/12/2002
600012878 | RHINOCORT |  ADRENALS | 12/14/2016
; 

Proc sort; by class; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 17:23:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-column-based-on-specific-sitution/m-p/459424#M70236</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-02T17:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new column based on specific sitution</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-column-based-on-specific-sitution/m-p/459425#M70237</link>
      <description>SQL join</description>
      <pubDate>Wed, 02 May 2018 17:24:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-column-based-on-specific-sitution/m-p/459425#M70237</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2018-05-02T17:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new column based on specific sitution</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-column-based-on-specific-sitution/m-p/459427#M70238</link>
      <description>&lt;P&gt;With just 500 obs, a format is the way to go. No sorting needed.&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 17:27:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-column-based-on-specific-sitution/m-p/459427#M70238</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-02T17:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new column based on specific sitution</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-column-based-on-specific-sitution/m-p/459429#M70239</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt;&amp;nbsp;From your previous questions and posts you should be able to do a SQL join. Can you please post what you've tried and the log indicating any errors you're getting or a descriptions of what the issue you're having?&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 17:30:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-column-based-on-specific-sitution/m-p/459429#M70239</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-02T17:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new column based on specific sitution</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-column-based-on-specific-sitution/m-p/459431#M70240</link>
      <description>&lt;P&gt;One important thing I would like to point out is the actual template data is 500 obs, while the actual dataset is s10K which is 20 time larger than the template data.&amp;nbsp;&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 17:32:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-column-based-on-specific-sitution/m-p/459431#M70240</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2018-05-02T17:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new column based on specific sitution</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-column-based-on-specific-sitution/m-p/459434#M70242</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;One important thing I would like to point out is the actual template data is 500 obs, while the actual dataset is s10K which is 20 time larger than the template data.&amp;nbsp;&amp;nbsp; Thanks.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And? 500 obs are still 500 obs and can&amp;nbsp;&lt;EM&gt;very&lt;/EM&gt; easily be handled with a format.&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 17:37:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-column-based-on-specific-sitution/m-p/459434#M70242</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-02T17:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new column based on specific sitution</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-column-based-on-specific-sitution/m-p/459436#M70243</link>
      <description>&lt;P&gt;Even if it was a million in this case it wouldn't really affect the code or results and probably not even the timing. We're talking about less than a minute for most of this on any decent machine (8GB RAM).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;One important thing I would like to point out is the actual template data is 500 obs, while the actual dataset is s10K which is 20 time larger than the template data.&amp;nbsp;&amp;nbsp; Thanks.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 17:38:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-column-based-on-specific-sitution/m-p/459436#M70243</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-02T17:38:07Z</dc:date>
    </item>
  </channel>
</rss>

