<?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 do I combine split rows of data in SAS? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-combine-split-rows-of-data-in-SAS/m-p/930484#M366090</link>
    <description>&lt;P&gt;First, I feel your pain. I once received a bunch of "data" in the form of Fillable PDF forms and had multiple issues with getting values of of PDF into a usable form.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My first try would be to start over. How did you get the tables from PDF to Excel? Acrobat reader export tool?&lt;/P&gt;
&lt;P&gt;Different PDF reader export? Copy and Paste?&lt;/P&gt;
&lt;P&gt;Did you do anything in Excel like examine the data for hidden rows/columns? Merged cells? before attempting to read the data into SAS? How did you get the data from Excel to SAS?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With my project I had to manually fix a number of recurring hidden/merged cells and sometimes copy the data from one cell in Excel to another after getting rid of the merged cells and un-hiding all the hidden row/columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Clean up the Excel, then save as CSV and read that file and you may have more luck.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With LAG function you can get the values from a previous row of data but without an example of data in the from of a working data step I'm not going to try. For example, you are showing things that aren't normally valid variable names.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However your example shows problems with just determining when and where a row was split. Which may mean you'll have better luck cleaning before reading into SAS if possible.&lt;/P&gt;</description>
    <pubDate>Fri, 31 May 2024 20:32:38 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-05-31T20:32:38Z</dc:date>
    <item>
      <title>How do I combine split rows of data in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-combine-split-rows-of-data-in-SAS/m-p/930476#M366089</link>
      <description>&lt;P&gt;Hello, I am analyzing data for a project. Unfortunately, the data was provided in tables in PDF documents. We imported the PDF tables into Excel and some of the data split into multiple rows. We then read the data into SAS for analysis. Is there a way in SAS to combine data in different rows without a linking ID (the linking ID itself is split). I've attached a sample of fake data below that has the same structural issues I am looking to resolve. Each row should start with "Initiating Action:" - any data in a row that does not have this needs to be combined with the row above it. Any recommendations for how I should proceed with cleaning this are much appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I have:&lt;/P&gt;
&lt;TABLE style="height: 378px; width: 600px;" width="600"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="127px" height="30px"&gt;Event Type&lt;/TD&gt;
&lt;TD width="96.7917px" height="30px"&gt;ID&lt;/TD&gt;
&lt;TD width="113.542px" height="30px"&gt;Case Type&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="127px" height="57px"&gt;Initiating Action: Pet&lt;/TD&gt;
&lt;TD width="96.7917px" height="57px"&gt;X-000-CV-2024-&lt;/TD&gt;
&lt;TD width="113.542px" height="57px"&gt;Admin&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="127px" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="96.7917px" height="30px"&gt;0123&lt;/TD&gt;
&lt;TD width="113.542px" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="127px" height="57px"&gt;Initiating Action:&lt;/TD&gt;
&lt;TD width="96.7917px" height="57px"&gt;X-000-CV-2024-&lt;/TD&gt;
&lt;TD width="113.542px" height="57px"&gt;Contract &amp;amp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="127px" height="30px"&gt;Complaint&lt;/TD&gt;
&lt;TD width="96.7917px" height="30px"&gt;4432&lt;/TD&gt;
&lt;TD width="113.542px" height="30px"&gt;Debts&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="127px" height="57px"&gt;Initiating Action: Pet&lt;/TD&gt;
&lt;TD width="96.7917px" height="57px"&gt;X-000-CV-2022-&lt;/TD&gt;
&lt;TD width="113.542px" height="57px"&gt;Admin&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="127px" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="96.7917px" height="30px"&gt;0681&lt;/TD&gt;
&lt;TD width="113.542px" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="127px" height="57px"&gt;Initiating Action:&lt;/TD&gt;
&lt;TD width="96.7917px" height="57px"&gt;X-000-CV-2023&lt;/TD&gt;
&lt;TD width="113.542px" height="57px"&gt;Miscellaneous&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="127px" height="30px"&gt;Complaint&lt;/TD&gt;
&lt;TD width="96.7917px" height="30px"&gt;0873&lt;/TD&gt;
&lt;TD width="113.542px" height="30px"&gt;Issue&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What it needs to look like:&lt;/P&gt;
&lt;TABLE style="width: 600px;" width="600"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="138"&gt;Event Type&lt;/TD&gt;
&lt;TD width="108"&gt;ID&lt;/TD&gt;
&lt;TD width="92"&gt;Case Type&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Initiating Action: Pet&lt;/TD&gt;
&lt;TD&gt;X-000-CV-2024-0123&lt;/TD&gt;
&lt;TD&gt;Admin&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Initiating Action: Complaint&lt;/TD&gt;
&lt;TD&gt;X-000-CV-2024-4432&lt;/TD&gt;
&lt;TD&gt;Contract &amp;amp; Debts&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Initiating Action: Pet&lt;/TD&gt;
&lt;TD&gt;X-000-CV-2022-0681&lt;/TD&gt;
&lt;TD&gt;Admin&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Initiating Action: Complaint&lt;/TD&gt;
&lt;TD&gt;X-000-CV-2023-0873&lt;/TD&gt;
&lt;TD&gt;Miscellaneous issue&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Fri, 31 May 2024 19:59:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-combine-split-rows-of-data-in-SAS/m-p/930476#M366089</guid>
      <dc:creator>MHines</dc:creator>
      <dc:date>2024-05-31T19:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do I combine split rows of data in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-combine-split-rows-of-data-in-SAS/m-p/930484#M366090</link>
      <description>&lt;P&gt;First, I feel your pain. I once received a bunch of "data" in the form of Fillable PDF forms and had multiple issues with getting values of of PDF into a usable form.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My first try would be to start over. How did you get the tables from PDF to Excel? Acrobat reader export tool?&lt;/P&gt;
&lt;P&gt;Different PDF reader export? Copy and Paste?&lt;/P&gt;
&lt;P&gt;Did you do anything in Excel like examine the data for hidden rows/columns? Merged cells? before attempting to read the data into SAS? How did you get the data from Excel to SAS?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With my project I had to manually fix a number of recurring hidden/merged cells and sometimes copy the data from one cell in Excel to another after getting rid of the merged cells and un-hiding all the hidden row/columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Clean up the Excel, then save as CSV and read that file and you may have more luck.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With LAG function you can get the values from a previous row of data but without an example of data in the from of a working data step I'm not going to try. For example, you are showing things that aren't normally valid variable names.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However your example shows problems with just determining when and where a row was split. Which may mean you'll have better luck cleaning before reading into SAS if possible.&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2024 20:32:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-combine-split-rows-of-data-in-SAS/m-p/930484#M366090</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-05-31T20:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do I combine split rows of data in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-combine-split-rows-of-data-in-SAS/m-p/930495#M366097</link>
      <description>&lt;P&gt;This is a RENAME exercise which can be automated.&amp;nbsp; Uses a version of the UPDATE trick.&amp;nbsp; You can use SQL to generate the rename statement.&amp;nbsp; Notice the issue with spacing sometimes you want the space others not.&amp;nbsp; I update this UPDATE statement example using UPDATEMODE option.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
   infile cards dsd dlm='09'x firstobs=2;
   length G_ 8;
   input  (Event ID Type) (:$64.);
   if event eq: 'Initiating' then G_ + 1;
   cards;
Event Type	ID	Case Type
Initiating Action: Pet	X-000-CV-2024-	Admin
 	0123	 
Initiating Action:	X-000-CV-2024-	Contract &amp;amp;
Complaint	4432	Debts
Initiating Action: Pet	X-000-CV-2022-	Admin
 	0681	 
Initiating Action:	X-000-CV-2023	Miscellaneous
Complaint	0873	Issue
;;;;
   run;
proc print;
   run; 
data want;
   update have(obs=0) have(rename=(Event=C_Event ID=C_ID Type=C_Type)) updatemode=nomissingcheck;
   by G_;
   array C_ C_:;
   array C Event ID Type;
   do over c_;
      c = catx(' ',of c C_);
      end;
   drop C_:;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 419px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96910i37819FD2A4E229F7/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jun 2024 15:47:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-combine-split-rows-of-data-in-SAS/m-p/930495#M366097</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2024-06-01T15:47:42Z</dc:date>
    </item>
  </channel>
</rss>

