<?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 Create separate rows based on the second/ third space in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-separate-rows-based-on-the-second-third-space/m-p/821545#M324345</link>
    <description>For example I have the data:&lt;BR /&gt;data have;&lt;BR /&gt;input name$;&lt;BR /&gt;cards;&lt;BR /&gt;Aaron Smith Andrew Knoi&lt;BR /&gt;Linda Jackson Betty Young&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;I want to create separate rows based on the second space like the data in the following.&lt;BR /&gt;data want;&lt;BR /&gt;input name$;&lt;BR /&gt;cards;&lt;BR /&gt;Aaron Smith&lt;BR /&gt;Andrew Knoi&lt;BR /&gt;Linda Jackson&lt;BR /&gt;Betty Young&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;How can create separate rows based on the second space? I tried to use scan but it seems to be only working for the first space. Thank you!</description>
    <pubDate>Tue, 05 Jul 2022 06:27:05 GMT</pubDate>
    <dc:creator>Feyng819</dc:creator>
    <dc:date>2022-07-05T06:27:05Z</dc:date>
    <item>
      <title>Create separate rows based on the second/ third space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-separate-rows-based-on-the-second-third-space/m-p/821545#M324345</link>
      <description>For example I have the data:&lt;BR /&gt;data have;&lt;BR /&gt;input name$;&lt;BR /&gt;cards;&lt;BR /&gt;Aaron Smith Andrew Knoi&lt;BR /&gt;Linda Jackson Betty Young&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;I want to create separate rows based on the second space like the data in the following.&lt;BR /&gt;data want;&lt;BR /&gt;input name$;&lt;BR /&gt;cards;&lt;BR /&gt;Aaron Smith&lt;BR /&gt;Andrew Knoi&lt;BR /&gt;Linda Jackson&lt;BR /&gt;Betty Young&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;How can create separate rows based on the second space? I tried to use scan but it seems to be only working for the first space. Thank you!</description>
      <pubDate>Tue, 05 Jul 2022 06:27:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-separate-rows-based-on-the-second-third-space/m-p/821545#M324345</guid>
      <dc:creator>Feyng819</dc:creator>
      <dc:date>2022-07-05T06:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: Create separate rows based on the second/ third space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-separate-rows-based-on-the-second-third-space/m-p/821552#M324352</link>
      <description>&lt;P&gt;Loop through the string, incrementing the loop counter by 2:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input name $80.;
cards;
Aaron Smith Andrew Knoi
Linda Jackson Betty Young
;

data want;
set have;
i = 1;
word = scan(name,i);
do while(word ne "");
  n_name = catx(" ",scan(name,i),scan(name,i+1));
  output;
  i = i + 2;
  word = scan(name,i);
end;
keep n_name;
rename n_name=name;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Jul 2022 08:05:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-separate-rows-based-on-the-second-third-space/m-p/821552#M324352</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-07-05T08:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: Create separate rows based on the second/ third space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-separate-rows-based-on-the-second-third-space/m-p/821575#M324367</link>
      <description>&lt;P&gt;It's actually easier if you create two variables instead of one:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  length first_name last_name $ 20;
  input first_name last_name @@;
cards;
Aaron Smith Andrew Knoi
Linda Jackson Betty Young
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Jul 2022 11:11:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-separate-rows-based-on-the-second-third-space/m-p/821575#M324367</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-07-05T11:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: Create separate rows based on the second/ third space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-separate-rows-based-on-the-second-third-space/m-p/821577#M324369</link>
      <description>&lt;P&gt;Can you add an example showing what should happen if the value has to separated at the third space?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2022 11:15:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-separate-rows-based-on-the-second-third-space/m-p/821577#M324369</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-07-05T11:15:29Z</dc:date>
    </item>
    <item>
      <title>Re: Create separate rows based on the second/ third space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-separate-rows-based-on-the-second-third-space/m-p/821581#M324371</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input name $40.;
cards;
Aaron Smith Andrew Knoi
Linda Jackson Betty Young
;
run;

data want;
 set have;
 call scan(name,2,p,l,' ');
 new_name=left(substr(name,1,p+l));output;
 new_name=left(substr(name,p+l));output;
 drop p l;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Jul 2022 11:57:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-separate-rows-based-on-the-second-third-space/m-p/821581#M324371</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-07-05T11:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: Create separate rows based on the second/ third space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-separate-rows-based-on-the-second-third-space/m-p/821630#M324388</link>
      <description>This works great! Thank you</description>
      <pubDate>Tue, 05 Jul 2022 15:07:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-separate-rows-based-on-the-second-third-space/m-p/821630#M324388</guid>
      <dc:creator>Feyng819</dc:creator>
      <dc:date>2022-07-05T15:07:15Z</dc:date>
    </item>
  </channel>
</rss>

