<?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 Text into new columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Text-into-new-columns/m-p/345791#M79607</link>
    <description>&lt;P&gt;I have the data below that is contained in one column. Please see below. I would like to create two new columns with headers "Africa-Wide" and "&lt;SPAN&gt;Asia-Pacific Region" with the data directly underneath that headername. The gap in-between records means a new header.Would you happen to know how I can create the new columns? Thanks.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Data&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Africa-wide&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Corporate/M&amp;amp;A (Band 4)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Dispute Resolution (Band 2)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Projects &amp;amp; Energy (Band 4)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;TMT (Band 1)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Asia-Pacific Region&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Arbitration (International) (Band 2)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Banking &amp;amp; Finance (Band 3)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Capital Markets: Debt (Band 3)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Capital Markets: Equity (Band 2)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Corporate/M&amp;amp;A (Band 1)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Corporate/M&amp;amp;A: Private Equity (Band 2)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Energy &amp;amp; Natural Resources (Band 4)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Life Sciences (Band 3)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Projects &amp;amp; Infrastructure (Band 4)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;TMT (Band 3)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
    <pubDate>Thu, 30 Mar 2017 15:15:40 GMT</pubDate>
    <dc:creator>cmoore</dc:creator>
    <dc:date>2017-03-30T15:15:40Z</dc:date>
    <item>
      <title>Text into new columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-into-new-columns/m-p/345791#M79607</link>
      <description>&lt;P&gt;I have the data below that is contained in one column. Please see below. I would like to create two new columns with headers "Africa-Wide" and "&lt;SPAN&gt;Asia-Pacific Region" with the data directly underneath that headername. The gap in-between records means a new header.Would you happen to know how I can create the new columns? Thanks.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Data&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Africa-wide&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Corporate/M&amp;amp;A (Band 4)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Dispute Resolution (Band 2)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Projects &amp;amp; Energy (Band 4)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;TMT (Band 1)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Asia-Pacific Region&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Arbitration (International) (Band 2)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Banking &amp;amp; Finance (Band 3)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Capital Markets: Debt (Band 3)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Capital Markets: Equity (Band 2)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Corporate/M&amp;amp;A (Band 1)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Corporate/M&amp;amp;A: Private Equity (Band 2)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Energy &amp;amp; Natural Resources (Band 4)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Life Sciences (Band 3)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Projects &amp;amp; Infrastructure (Band 4)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;TMT (Band 3)&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 30 Mar 2017 15:15:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-into-new-columns/m-p/345791#M79607</guid>
      <dc:creator>cmoore</dc:creator>
      <dc:date>2017-03-30T15:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: Text into new columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-into-new-columns/m-p/345793#M79609</link>
      <description>&lt;P&gt;Have you already read this data into SAS?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 15:21:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-into-new-columns/m-p/345793#M79609</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-30T15:21:44Z</dc:date>
    </item>
    <item>
      <title>Re: Text into new columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-into-new-columns/m-p/345795#M79611</link>
      <description>&lt;P&gt;Yes as a CSV file. Just wanted to know the syntax to manipulate the data into those 2 new columns. That is just a small sample of data. I have 500 rows of data contained in the one column.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 15:31:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-into-new-columns/m-p/345795#M79611</guid>
      <dc:creator>cmoore</dc:creator>
      <dc:date>2017-03-30T15:31:30Z</dc:date>
    </item>
    <item>
      <title>Re: Text into new columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-into-new-columns/m-p/345808#M79616</link>
      <description>&lt;P&gt;A CSV file is not a SAS data set.&lt;/P&gt;
&lt;P&gt;The real question is are there exactly two "groups" of data? If not you would need to know how many different groups there are before hand and have some fairly obnoxious code. Plus "column heading" as a variable&amp;nbsp;name cannot contain&amp;nbsp;dashes or spaces to the values such as "Africa-Wide" would have to be a variable label.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Generally is much better to have one or more variables that hold the group indicators and have the values appear on each row. Then that variable would be used for grouping in reports and such.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The below demonstrates this approach and one example of BY processing using the grouping variable. Use variable names you like and add variable labels for prettier output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
   infile datalines truncover dsd;
   informat string $50.;
   input string $;
datalines;
Africa-wide 
Corporate/M&amp;amp;A (Band 4)  
Dispute Resolution (Band 2)  
Projects &amp;amp; Energy (Band 4)  
TMT (Band 1)  
  
Asia-Pacific Region 
Arbitration (International) (Band 2)  
Banking &amp;amp; Finance (Band 3)  
Capital Markets: Debt (Band 3)  
Capital Markets: Equity (Band 2)  
Corporate/M&amp;amp;A (Band 1)  
Corporate/M&amp;amp;A: Private Equity (Band 2)  
Energy &amp;amp; Natural Resources (Band 4)  
Life Sciences (Band 3)  
Projects &amp;amp; Infrastructure (Band 4)  
TMT (Band 3)  
;
run;

data want;
   set have;
   length area $ 50;
   retain area;
   if _n_=1 then area=string;
   else if missing(area) then area=string;
   if missing(string) then call missing(area);
   if not missing(area) then output;
run;

proc print data=want noobs;
   by area;
   var string;
run;
&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Mar 2017 16:00:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-into-new-columns/m-p/345808#M79616</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-30T16:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: Text into new columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-into-new-columns/m-p/346052#M79727</link>
      <description>&lt;P&gt;Thanks a lot for your help. Works great.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 07:07:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-into-new-columns/m-p/346052#M79727</guid>
      <dc:creator>cmoore</dc:creator>
      <dc:date>2017-03-31T07:07:27Z</dc:date>
    </item>
  </channel>
</rss>

