<?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: Creating new columns based on contents of a previous column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-columns-based-on-contents-of-a-previous-column/m-p/207011#M38487</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This may or may not suit your needs, take a look at this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;infile cards dsd;&lt;/P&gt;&lt;P&gt;input Customer_number $ Product_Code $&amp;nbsp; Amount;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;C123456,C1,100&lt;/P&gt;&lt;P&gt;C123457,F2,200&lt;/P&gt;&lt;P&gt;C127890,P3,150&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=have out=want(drop=_name_);by customer_number product_code amount;id product_code;var product_code;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Depending on what this will be used for you might want to think about proc format too.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Apr 2015 12:54:39 GMT</pubDate>
    <dc:creator>Steelers_In_DC</dc:creator>
    <dc:date>2015-04-30T12:54:39Z</dc:date>
    <item>
      <title>Creating new columns based on contents of a previous column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-columns-based-on-contents-of-a-previous-column/m-p/207006#M38482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am looking to be able to create additional columns in a SAS data set which are populated with a 1 or 0 based on whether &lt;/P&gt;&lt;P&gt;the entry in a previous column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;eg if I wanted to create 1 additional column I would do this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test1;&lt;/P&gt;&lt;P&gt;set base_data;&lt;/P&gt;&lt;P&gt;if column1 = 'entry1' then entry1 = 1; else entry1 = 0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and if i wanted to create 2 additional columns I would do it similarly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;data test1;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;set base_data;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;if column1 = 'entry1' then entry1 = 1; else entry1 = 0;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;if column1 = 'entry2' then entry2 = 1; else entry2 = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;run;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;However I have a lot of distinct entries that could be in the column and I don't want to have to create loads of if else statements.&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;I am wondering if it's possible to create a sinlge if else statement using macros variables that basically says if &lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;if column1 = x then x = 1 else x = 0 for all x that exist. Note all x are text fields&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;It sounds simple on the face of it but I have been unable to figure out something which works. &lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Thanks&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Stephen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Apr 2015 11:18:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-new-columns-based-on-contents-of-a-previous-column/m-p/207006#M38482</guid>
      <dc:creator>troopon</dc:creator>
      <dc:date>2015-04-30T11:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new columns based on contents of a previous column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-columns-based-on-contents-of-a-previous-column/m-p/207007#M38483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;can you give an example of the type of variables you are talking about?&amp;nbsp; Maybe a few lines of the before dataset?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Apr 2015 11:32:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-new-columns-based-on-contents-of-a-previous-column/m-p/207007#M38483</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-04-30T11:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new columns based on contents of a previous column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-columns-based-on-contents-of-a-previous-column/m-p/207008#M38484</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This may be a fit for proc transpose.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Apr 2015 11:58:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-new-columns-based-on-contents-of-a-previous-column/m-p/207008#M38484</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-04-30T11:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new columns based on contents of a previous column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-columns-based-on-contents-of-a-previous-column/m-p/207009#M38485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Simple, two quick options I see, though just guessing here as you provide no test data/required output:&lt;/P&gt;&lt;P&gt;1) Arrays:&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array elements &lt;LI&gt; entry1-entry10;&lt;/LI&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to 10;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if elements&lt;I&gt;=column then elements&lt;I&gt;="1";&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) create a dataset with distinct values:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table LOOP as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; distinct COLUMN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HAVE;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;Then use this to generate your code:&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set LOOP end=last;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _n_=1 then call execute('data want; set have;');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute(' if column=entry'||strip(put(_n_,best.))|' then ...');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if last then call execute('run;');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Apr 2015 12:05:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-new-columns-based-on-contents-of-a-previous-column/m-p/207009#M38485</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-04-30T12:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new columns based on contents of a previous column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-columns-based-on-contents-of-a-previous-column/m-p/207010#M38486</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;it's a sales type table so the table looks like this. There are lots more fields in the original dataset but not anything important&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Customer number&amp;nbsp;&amp;nbsp; Product Code&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Amount&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;C123456&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; £100&lt;/P&gt;&lt;P&gt;C123457&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; £200&lt;/P&gt;&lt;P&gt;C127890&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; P3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; £150&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and I want to create&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Customer number&amp;nbsp;&amp;nbsp; Product Code&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Amount&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F2&amp;nbsp;&amp;nbsp;&amp;nbsp; F3&amp;nbsp;&amp;nbsp; P2&amp;nbsp;&amp;nbsp; P3&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;C123456&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; £100&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;C123457&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; £200&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;C127890&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; P3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; £150&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;but I don't want to write an if statement for every product code like my original post has.&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;This is only a few lines so obviously not all codes covered. There is only as many columns extra as distinct codes&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Apr 2015 12:37:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-new-columns-based-on-contents-of-a-previous-column/m-p/207010#M38486</guid>
      <dc:creator>troopon</dc:creator>
      <dc:date>2015-04-30T12:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new columns based on contents of a previous column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-columns-based-on-contents-of-a-previous-column/m-p/207011#M38487</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This may or may not suit your needs, take a look at this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;infile cards dsd;&lt;/P&gt;&lt;P&gt;input Customer_number $ Product_Code $&amp;nbsp; Amount;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;C123456,C1,100&lt;/P&gt;&lt;P&gt;C123457,F2,200&lt;/P&gt;&lt;P&gt;C127890,P3,150&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=have out=want(drop=_name_);by customer_number product_code amount;id product_code;var product_code;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Depending on what this will be used for you might want to think about proc format too.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Apr 2015 12:54:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-new-columns-based-on-contents-of-a-previous-column/m-p/207011#M38487</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-04-30T12:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new columns based on contents of a previous column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-columns-based-on-contents-of-a-previous-column/m-p/207012#M38488</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;data have;
infile cards dsd;
input Customer_number $ Product_Code $&amp;nbsp; Amount;
cards;
C123456,C1,100
C123457,F2,200
C127890,P3,150
;
run;
proc sql noprint;
 select distinct Product_Code into : list separated by ' ' from have;
quit;
data want;
 set have;
 array x{*} &amp;amp;list ;
 do i=1 to dim(x);
&amp;nbsp; if Product_Code=vname(x{i}) then x{i}=1;
&amp;nbsp;&amp;nbsp; else x{i}=0;
 end;
 drop i;
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Apr 2015 14:56:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-new-columns-based-on-contents-of-a-previous-column/m-p/207012#M38488</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-04-30T14:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new columns based on contents of a previous column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-columns-based-on-contents-of-a-previous-column/m-p/207013#M38489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is great thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am a bit of a SAS novice so would not have ever been able to come up with that. Not entirely sure I understand exactly how it works but I'll work through it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stephen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Apr 2015 15:04:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-new-columns-based-on-contents-of-a-previous-column/m-p/207013#M38489</guid>
      <dc:creator>troopon</dc:creator>
      <dc:date>2015-04-30T15:04:30Z</dc:date>
    </item>
  </channel>
</rss>

