<?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: How I can split character variable into multiple rows?? in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/How-I-can-split-character-variable-into-multiple-rows/m-p/189329#M9854</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assuming your data resides in an Excel workbook, you could try something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;libname xl Excel "&lt;SPAN style="color: #800000;"&gt;&amp;amp;sasforum.\Datasets\hyunjoo DATA.xlsx&lt;/SPAN&gt;" access=readonly mixed=yes;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data want;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set xl.'Sheet1$'n;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;array F&lt;/STRONG&gt;&lt;LI&gt;&lt;STRONG&gt; _character_;&lt;/STRONG&gt;&lt;/LI&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;array F_[20] $200 _temporary_; /* 20 is &amp;gt;= the number of columns in the table */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do i = 1 to dim(F);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; F_&lt;I&gt; = F&lt;I&gt;;&lt;/I&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do j = 1 to 10; /* 10 is &amp;gt;= the max number of lines in a cell */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i = 1 to dim(F);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F&lt;I&gt; = scan(F_&lt;I&gt;,j,'0A'x,'M');&lt;/I&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if catx(of F&lt;/STRONG&gt;&lt;LI&gt;&lt;STRONG&gt;) ne "" then output;&lt;/STRONG&gt;&lt;/LI&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;drop i j;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;libname xl clear;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc print data=want noobs; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 06 Sep 2014 02:40:29 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2014-09-06T02:40:29Z</dc:date>
    <item>
      <title>How I can split character variable into multiple rows??</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-I-can-split-character-variable-into-multiple-rows/m-p/189327#M9852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;IMG __jive_id="7327" alt="Data example.PNG" class="jive-image-thumbnail jive-image" height="402" src="https://communities.sas.com/legacyfs/online/7327_Data example.PNG" width="1386" /&gt;&lt;/P&gt;&lt;P&gt;I have a dataset like this.&lt;/P&gt;&lt;P&gt;What I want to do it with SAS is split one blank into multiple rows&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Investor Group&lt;/P&gt;&lt;P&gt;STL PLC&lt;/P&gt;&lt;P&gt;LSI Logic Corp&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;are in one blank&lt;/P&gt;&lt;P&gt;I want to split it into 3 rows&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I do this with SAS??&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Sep 2014 00:35:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-I-can-split-character-variable-into-multiple-rows/m-p/189327#M9852</guid>
      <dc:creator>hyunjoo_min</dc:creator>
      <dc:date>2014-09-06T00:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: How I can split character variable into multiple rows??</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-I-can-split-character-variable-into-multiple-rows/m-p/189328#M9853</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please attach a sample of your data as a .csv file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From what I can see I would assume that the data needs to be read into SAS row by row. The values in a single cell will map as a single string into a SAS variable. I assume that this single string breaks so nicely within a cell because there are line feeds (LF) in these strings. If so then one could parse the strings and split them up into multiple observations using LF as the delimiter.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;But: Looking at your screen-shot the values in the last column look like something which then would have to be repeated for all rows.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;If you want us to provide a realistic solution you need to attach a sample of your real data. &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Sep 2014 02:29:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-I-can-split-character-variable-into-multiple-rows/m-p/189328#M9853</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-09-06T02:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: How I can split character variable into multiple rows??</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-I-can-split-character-variable-into-multiple-rows/m-p/189329#M9854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assuming your data resides in an Excel workbook, you could try something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;libname xl Excel "&lt;SPAN style="color: #800000;"&gt;&amp;amp;sasforum.\Datasets\hyunjoo DATA.xlsx&lt;/SPAN&gt;" access=readonly mixed=yes;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data want;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set xl.'Sheet1$'n;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;array F&lt;/STRONG&gt;&lt;LI&gt;&lt;STRONG&gt; _character_;&lt;/STRONG&gt;&lt;/LI&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;array F_[20] $200 _temporary_; /* 20 is &amp;gt;= the number of columns in the table */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do i = 1 to dim(F);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; F_&lt;I&gt; = F&lt;I&gt;;&lt;/I&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do j = 1 to 10; /* 10 is &amp;gt;= the max number of lines in a cell */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i = 1 to dim(F);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F&lt;I&gt; = scan(F_&lt;I&gt;,j,'0A'x,'M');&lt;/I&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if catx(of F&lt;/STRONG&gt;&lt;LI&gt;&lt;STRONG&gt;) ne "" then output;&lt;/STRONG&gt;&lt;/LI&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;drop i j;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;libname xl clear;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc print data=want noobs; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Sep 2014 02:40:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-I-can-split-character-variable-into-multiple-rows/m-p/189329#M9854</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-09-06T02:40:29Z</dc:date>
    </item>
  </channel>
</rss>

