<?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 CSV data clean- convert specific rows into columns in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/CSV-data-clean-convert-specific-rows-into-columns/m-p/512116#M2299</link>
    <description>&lt;P&gt;Dear community, I am trying to save time. I have Excel Data cleaning work. Unfortunately the data comes all in one column but I can't transpose it simply into rows. I need to extract specific information as in the example want file. Can someone please help.&lt;/P&gt;&lt;P&gt;This is the have file:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Walmart Inc.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;NYSE : WMT&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;D-U-N-S# 051957769&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Berkshire Hathaway Inc.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;NYSE : BRK.B&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;D-U-N-S# 001024314&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And this is the want file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Company Name&lt;/TD&gt;&lt;TD&gt;Exchange&lt;/TD&gt;&lt;TD&gt;Ticker&lt;/TD&gt;&lt;TD&gt;D-U-N-S#&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Walmart Inc.&lt;/TD&gt;&lt;TD&gt;NYSE&lt;/TD&gt;&lt;TD&gt;WMT&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;51957769&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Berkshire Hathaway Inc.&lt;/TD&gt;&lt;TD&gt;NYSE&lt;/TD&gt;&lt;TD&gt;BRK.B&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1024314&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
    <pubDate>Fri, 16 Nov 2018 02:01:53 GMT</pubDate>
    <dc:creator>Agent1592</dc:creator>
    <dc:date>2018-11-16T02:01:53Z</dc:date>
    <item>
      <title>CSV data clean- convert specific rows into columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/CSV-data-clean-convert-specific-rows-into-columns/m-p/512116#M2299</link>
      <description>&lt;P&gt;Dear community, I am trying to save time. I have Excel Data cleaning work. Unfortunately the data comes all in one column but I can't transpose it simply into rows. I need to extract specific information as in the example want file. Can someone please help.&lt;/P&gt;&lt;P&gt;This is the have file:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Walmart Inc.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;NYSE : WMT&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;D-U-N-S# 051957769&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Berkshire Hathaway Inc.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;NYSE : BRK.B&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;D-U-N-S# 001024314&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And this is the want file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Company Name&lt;/TD&gt;&lt;TD&gt;Exchange&lt;/TD&gt;&lt;TD&gt;Ticker&lt;/TD&gt;&lt;TD&gt;D-U-N-S#&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Walmart Inc.&lt;/TD&gt;&lt;TD&gt;NYSE&lt;/TD&gt;&lt;TD&gt;WMT&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;51957769&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Berkshire Hathaway Inc.&lt;/TD&gt;&lt;TD&gt;NYSE&lt;/TD&gt;&lt;TD&gt;BRK.B&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1024314&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 16 Nov 2018 02:01:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/CSV-data-clean-convert-specific-rows-into-columns/m-p/512116#M2299</guid>
      <dc:creator>Agent1592</dc:creator>
      <dc:date>2018-11-16T02:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: Excel (CSV) data clean- convert specific rows into columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/CSV-data-clean-convert-specific-rows-into-columns/m-p/512127#M2302</link>
      <description>&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;CSV&amp;nbsp;&lt;/STRONG&gt;&lt;STRONG&gt;is not Excel!!&lt;/STRONG&gt;&lt;/U&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As for the data, if its all in that format, then read line, and retain the variables, something like:&lt;/P&gt;
&lt;PRE&gt;data want;
  infile "have.csv" dlm=",";
  length company exchange ticker duns buff $200;
  retain company exchange ticker duns;
  input buff $;
  if index(buff,":") then do;
    exchange=scan(buff,1,":");
    ticker=scan(buff,2,":");
  end;
  else if substr(buff,1,4)="D-U-" then do;
    duns=scan(buff,2,"#");
    output;
    company="";
    exchange="";
    ticker="";
    duns="";
  end;
  else company=buff;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Nov 2018 09:31:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/CSV-data-clean-convert-specific-rows-into-columns/m-p/512127#M2302</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-12T09:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: Excel (CSV) data clean- convert specific rows into columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/CSV-data-clean-convert-specific-rows-into-columns/m-p/512186#M2307</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options validvarname=any;
data have;
infile 'c:\temp\have.csv' truncover termstr=lf;
input x $200.;
if not findc(x,':#') then group=0;
group+1;
run;
data temp;
 set have;
 if group=1 then do;n+1;name='CompanyName      ';v=x;output;end;
 else if findc(x,':') then do;
 name='Exchange';v=scan(x,1,':');output;
 name='Ticker';v=scan(x,-1,':');output;
 end;
 else if findc(x,'#') then do;
 name='D-U-N-S#';v=scan(x,-1,' ');output;
 end;
drop x group;
run;
proc transpose data=temp out=want;
by n;
var v;
id name;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Nov 2018 13:39:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/CSV-data-clean-convert-specific-rows-into-columns/m-p/512186#M2307</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-11-12T13:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: Excel (CSV) data clean- convert specific rows into columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/CSV-data-clean-convert-specific-rows-into-columns/m-p/512459#M2346</link>
      <description>&lt;P&gt;Thank you. I appreciate your quick response. This is an excellent solution!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 06:04:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/CSV-data-clean-convert-specific-rows-into-columns/m-p/512459#M2346</guid>
      <dc:creator>Agent1592</dc:creator>
      <dc:date>2018-11-13T06:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: Excel (CSV) data clean- convert specific rows into columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/CSV-data-clean-convert-specific-rows-into-columns/m-p/512460#M2347</link>
      <description>Thank you sir. Excellent solution as well.</description>
      <pubDate>Tue, 13 Nov 2018 06:05:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/CSV-data-clean-convert-specific-rows-into-columns/m-p/512460#M2347</guid>
      <dc:creator>Agent1592</dc:creator>
      <dc:date>2018-11-13T06:05:47Z</dc:date>
    </item>
  </channel>
</rss>

