<?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: Split a row based into two rows in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Split-a-row-based-into-two-rows/m-p/638863#M189990</link>
    <description>&lt;P&gt;Actual data example would be good.&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does not have to contain sensitive data but should behave like your actual data.&lt;/P&gt;
&lt;P&gt;Then provide what the exact output for that given example should look like. Also is the output supposed to be a data set, a report, a text file or what. This output implies the example data should be small enough that you can do the result by hand.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Apr 2020 03:20:25 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-04-10T03:20:25Z</dc:date>
    <item>
      <title>Split a row based into two rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-a-row-based-into-two-rows/m-p/638847#M189985</link>
      <description>&lt;P&gt;I have created output for a customer that has (in very simple form):&lt;/P&gt;&lt;P&gt;id1 vara varb varc vard vare id2 varf varg varh.&lt;/P&gt;&lt;P&gt;id1 has a numeric value of, say 42, id2 will always have a value of id1+1 (i.e. 43 in this case). vara-varh are character values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i now need to split each row into based on the values of id1 and id2 to be:&lt;/P&gt;&lt;P&gt;id vara varb varc vard vare varf varg varh&lt;/P&gt;&lt;P&gt;42 ........&lt;/P&gt;&lt;P&gt;43........&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been trying to read id1 and then say if id2 =id1+1 then output but I still don't get the split right. I've been thinking how to force SAS to stop reading the line after vare then to drop down to the next line but don't know how to do that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't want to go back to square 1 and start the job again as i think the customer may want the data in the original format once they test it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any assistance or tips appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gordon&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2020 01:27:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-a-row-based-into-two-rows/m-p/638847#M189985</guid>
      <dc:creator>gordononline</dc:creator>
      <dc:date>2020-04-10T01:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: Split a row based into two rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-a-row-based-into-two-rows/m-p/638852#M189987</link>
      <description>&lt;P&gt;What kind of "output" did you create?&amp;nbsp; Is it a text file? Something else?&lt;/P&gt;
&lt;P&gt;Why does the first ID have a different set of variables than the second ID?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or did you mean that they both have the same set of variables and are just trying to show different values.&lt;/P&gt;
&lt;P&gt;Are there always two observations on each line of text?&amp;nbsp; That is simple using the double trailing&amp;nbsp;@ on the INPUT statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  infile 'myfile.txt' ;
  input id var1-var5 @@;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2020 02:08:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-a-row-based-into-two-rows/m-p/638852#M189987</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-10T02:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: Split a row based into two rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-a-row-based-into-two-rows/m-p/638863#M189990</link>
      <description>&lt;P&gt;Actual data example would be good.&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does not have to contain sensitive data but should behave like your actual data.&lt;/P&gt;
&lt;P&gt;Then provide what the exact output for that given example should look like. Also is the output supposed to be a data set, a report, a text file or what. This output implies the example data should be small enough that you can do the result by hand.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2020 03:20:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-a-row-based-into-two-rows/m-p/638863#M189990</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-10T03:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: Split a row based into two rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-a-row-based-into-two-rows/m-p/638880#M189999</link>
      <description>&lt;P&gt;Here's my partial solution:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; test;&lt;/P&gt;&lt;P&gt;input @&lt;STRONG&gt;1&lt;/STRONG&gt; id1 &lt;STRONG&gt;2.&lt;/STRONG&gt; @&lt;STRONG&gt;4&lt;/STRONG&gt; a1 $1. @&lt;STRONG&gt;6&lt;/STRONG&gt; b2 $1. @&lt;STRONG&gt;8&lt;/STRONG&gt; c3 $1. @&lt;STRONG&gt;10&lt;/STRONG&gt; d4 $1. @&lt;STRONG&gt;12&lt;/STRONG&gt; e5 $1. @&lt;STRONG&gt;14&lt;/STRONG&gt; id2 &lt;STRONG&gt;2.&lt;/STRONG&gt; @&lt;STRONG&gt;17&lt;/STRONG&gt; f6 $1. @&lt;STRONG&gt;19&lt;/STRONG&gt; g7 &lt;A href="mailto:$1.@21" target="_blank"&gt;$1.@&lt;STRONG&gt;21&lt;/STRONG&gt;&lt;/A&gt; h8 $1. @&lt;STRONG&gt;23&lt;/STRONG&gt; i9 $1. @&lt;STRONG&gt;25&lt;/STRONG&gt; j10 $1.;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;19 a b c d e 42 g h j k l&lt;/P&gt;&lt;P&gt;34 e r t y u 54 q w e r t&lt;/P&gt;&lt;P&gt;57 a s d f g 66 q w e r t&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; new1;&lt;/P&gt;&lt;P&gt;set test;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; new2;&lt;/P&gt;&lt;P&gt;set test;&lt;/P&gt;&lt;P&gt;drop id1;&lt;/P&gt;&lt;P&gt;rename id2 =id1;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; new3;&lt;/P&gt;&lt;P&gt;set new1 new2;&lt;/P&gt;&lt;P&gt;drop id2;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;print&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2020 06:10:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-a-row-based-into-two-rows/m-p/638880#M189999</guid>
      <dc:creator>gordononline</dc:creator>
      <dc:date>2020-04-10T06:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: Split a row based into two rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-a-row-based-into-two-rows/m-p/638975#M190020</link>
      <description>&lt;P&gt;If you only need to output two records for each current record, with only the id being different, couldn't you just use something like the following?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop=id2);
  set test;
  output;
  id1=id2;
  output;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2020 14:21:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-a-row-based-into-two-rows/m-p/638975#M190020</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2020-04-10T14:21:41Z</dc:date>
    </item>
  </channel>
</rss>

