<?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 to delete specific rows from an external file? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74536#M16058</link>
    <description>Hi Curtis, &lt;BR /&gt;
&lt;BR /&gt;
WOW!! This is soo awesome... you are amazing.. I just cant thank you enough..... Thanks a million for your help. &lt;BR /&gt;
&lt;BR /&gt;
Also, if I'm not troubling you, would you be kind enough to explain the logic to me.... In my initial code i had a similar flow.... but I just need to make sure that I understand the logic... &lt;BR /&gt;
&lt;BR /&gt;
Once again ...&lt;BR /&gt;
&lt;BR /&gt;
Many Many Many Thanks,&lt;BR /&gt;
Jerry</description>
    <pubDate>Thu, 08 Oct 2009 00:59:01 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-10-08T00:59:01Z</dc:date>
    <item>
      <title>How to delete specific rows from an external file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74521#M16043</link>
      <description>Hi Guys,&lt;BR /&gt;
&lt;BR /&gt;
I'm really struggling with a rather intriguing problem. I have a file of XML data that I need to read from SAS. The XML statements occur on two separate lines and only those statements with a valid value needs to be read and the others need to be deleted before writing the statements to a new file. &lt;BR /&gt;
&lt;BR /&gt;
Here's an example:&lt;BR /&gt;
&lt;BR /&gt;
My file consists of the following data:&lt;BR /&gt;
&lt;BR /&gt;
 &lt;ROW&gt;&lt;BR /&gt;
    &lt;CELL styleid="s100"&gt;&lt;DATA type="String"&gt;Cost of Goods Sold&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL index="3" styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="Number"&amp;gt;2285.4549999999999&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="Number"&amp;gt;2087.239&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="Number"&amp;gt;2082.4839999999999&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="Number"&amp;gt;2537.913&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="Number"&amp;gt;4086.61&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="Number"&amp;gt;5616.8729999999996&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="Number"&amp;gt;6391.4539999999997&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="Number"&amp;gt;7060.6840000000002&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="String"&amp;gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="String"&amp;gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="String"&amp;gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="String"&amp;gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="String"&amp;gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="String"&amp;gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="String"&amp;gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="String"&amp;gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="String"&amp;gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="String"&amp;gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="String"&amp;gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="String"&amp;gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="String"&amp;gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="String"&amp;gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
   &lt;/ROW&gt;&lt;BR /&gt;
&lt;BR /&gt;
From this file I need to read in the valid statements beginning at line &lt;ROW&gt;. So the valid lines will be:&lt;BR /&gt;
&lt;BR /&gt;
 &lt;ROW&gt;&lt;BR /&gt;
    &lt;CELL styleid="s100"&gt;&lt;DATA type="String"&gt;Cost of Goods Sold&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL index="3" styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="Number"&amp;gt;2285.4549999999999&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="Number"&amp;gt;2087.239&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="Number"&amp;gt;2082.4839999999999&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
    &lt;CELL styleid="s94" formula="=IF(R[-498]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[-498]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="Number"&amp;gt;2537.913&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
&lt;BR /&gt;
and the rest of the lines after  ss:Type="Number"&amp;gt;2537.913&lt;/ROW&gt;&lt;/ROW&gt; needs to be deleted or just these lines need to be written to a new file and end it with  tag. &lt;BR /&gt;
When the program encounters line #2  ss:Type="Number"&amp;gt;2537.913 with a number between the ss:Type="Number"&amp;gt; and  then the line before that beginning &lt;CELL till=""&gt;&lt;DATA needs="" to="" be="" captured.="" any="" statement="" on="" line=""&gt;&lt;/DATA&gt;&lt;/CELL&gt; is invalid hence delete this line and the line above that statement. &lt;BR /&gt;
&lt;BR /&gt;
I was able to successfully delete all occurrences of  ss:Type="Number"&amp;gt; but I'm still trying to figure out how to delete the statements above each occurances of ss:Type="Number"&amp;gt;.&lt;BR /&gt;
&lt;BR /&gt;
I would really appreciate your help on this matter.&lt;BR /&gt;
&lt;BR /&gt;
Many Thanks,&lt;BR /&gt;
Jerry</description>
      <pubDate>Tue, 06 Oct 2009 02:05:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74521#M16043</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-10-06T02:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete specific rows from an external file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74522#M16044</link>
      <description>Hi:&lt;BR /&gt;
  I'm having trouble figuring out what you want to do. Some possibilities that occur to me are these:&lt;BR /&gt;
1) You have a Spreadsheet Markup Language XML file created by Excel and you are trying to read that XML into a SAS data set &lt;BR /&gt;
---If this is what you are trying to do (get from Excel to a SAS dataset and if your data are in this form of XML, I would recommend resaving the file in Excel as an Excel 97-2003 .XLS binary file and then read the file using the SAS Libname engine for Excel or with PROC IMPORT.&lt;BR /&gt;
                &lt;BR /&gt;
2) You are trying to -alter- some Spreadsheet Markup Language XML so that the form you have (shown at the top of your post)  turns into the shortened XML that you show at the bottom of your post.&lt;BR /&gt;
---If this is what you are trying to do (transform the XML from one form into another), then you might try a DATA step program with some string manipulation with character functions. I'm not sure whether the XML Mapper would help you here or not. Since the starting XML looks fairly regular, you could treat everything within &amp;lt;Cell&amp;gt; and &amp;lt;/Cell&amp;gt; as one huge character variable and/or everything within one &amp;lt;Data&amp;gt; and &amp;lt;/Data&amp;gt; as one huge character variable. But it sort of depends on what you're trying to do in the long run.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
3) Or you are trying to do something else??? &lt;BR /&gt;
&lt;BR /&gt;
Did the data originally come from a SAS dataset? Are you trying to create a file for Excel??? Or create a file for Excel using SAS to clean up some XML???&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Tue, 06 Oct 2009 03:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74522#M16044</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-10-06T03:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete specific rows from an external file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74523#M16045</link>
      <description>Hi Cynthia,&lt;BR /&gt;
&lt;BR /&gt;
Thanks a million for your response. &lt;BR /&gt;
&lt;BR /&gt;
The excel file is generated as a result of a webquery. For ex: a client wants to get historical data for a company such as IBM for years 2000 - 2004. Once the client selects the required parameters via the web the SAS is called which will then extract the required data from the corresponding datasets and outputs the result in the form of xls spreadsheet. &lt;BR /&gt;
&lt;BR /&gt;
The problem is, since the whole process is web based, SAS is run from an unix environment which does not support DDE. Moreover, the excel spreadsheet is a pre-formatted template with formulas in each cell. And selected rows have a continuous border based on the style ID. &lt;BR /&gt;
&lt;BR /&gt;
The excel template is formatted to 26 columns and 1396 rows. So if the user selects data for only 4 years then when the template is populated with the data the rest of the empty columns that have the borders should be hidden. &lt;BR /&gt;
&lt;BR /&gt;
I found out that within the &lt;ROW&gt; and &lt;/ROW&gt; if you remove the the cell tag:&lt;BR /&gt;
&lt;BR /&gt;
&lt;CELL styleid="s81" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
      ss:Type="String"&amp;gt;&lt;/DATA&gt;&lt;/CELL&gt; **** NO DATA INBETWEEN&lt;BR /&gt;
&lt;BR /&gt;
the borders will be removed. &lt;BR /&gt;
&lt;BR /&gt;
So my goal is to have sas search the entire xml tags and find and remove all instances of &lt;CELL .......=""&gt;&lt;/CELL&gt; where there is no data between ss:Type="String"&amp;gt;&lt;BR /&gt;
&lt;BR /&gt;
Since I'm running the process from shell I read in the original template in XML form.&lt;BR /&gt;
&lt;BR /&gt;
I hope this clears up your doubts.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Jerry</description>
      <pubDate>Tue, 06 Oct 2009 12:36:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74523#M16045</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-10-06T12:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete specific rows from an external file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74524#M16046</link>
      <description>Jerry,&lt;BR /&gt;
&lt;BR /&gt;
Does this code answer your question?&lt;BR /&gt;
&lt;BR /&gt;
filename in "c:\temp\junk.xml";&lt;BR /&gt;
filename out "c:\temp\junk2.xml";&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
  infile in lrecl=120;&lt;BR /&gt;
  file out lrecl=4000;&lt;BR /&gt;
  length CellHolder $4000;&lt;BR /&gt;
  retain CellHolder;&lt;BR /&gt;
&lt;BR /&gt;
  input;&lt;BR /&gt;
&lt;BR /&gt;
  if _infile_ =: '&lt;CELL&gt;
     CellHolder = _infile_;&lt;BR /&gt;
  end;&lt;BR /&gt;
  if CellHolder = "" then do;&lt;BR /&gt;
    put _infile_;&lt;BR /&gt;
  end;    &lt;BR /&gt;
  else do;&lt;BR /&gt;
    CellHolder = cats(CellHolder,_infile_);&lt;BR /&gt;
    if substr(CellHolder,length(CellHolder)-6) = '&lt;/CELL&gt;' then &lt;BR /&gt;
      do;&lt;BR /&gt;
        if index(CellHolder,"&amp;gt;") = 0 then put CellHolder;&lt;BR /&gt;
        CellHolder = "";&lt;BR /&gt;
      end;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 06 Oct 2009 15:42:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74524#M16046</guid>
      <dc:creator>CurtisMack</dc:creator>
      <dc:date>2009-10-06T15:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete specific rows from an external file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74525#M16047</link>
      <description>Hi:&lt;BR /&gt;
  Here's what I don't understand about what you're trying to do. You said:&lt;BR /&gt;
&lt;B&gt;&lt;BR /&gt;
Once the client selects the required parameters via the web the &lt;U&gt;SAS &lt;/U&gt; is called which will then extract the required data from the corresponding datasets and &lt;U&gt;SAS&lt;/U&gt; outputs the result in the form of xls spreadsheet. &lt;BR /&gt;
&lt;/B&gt;&lt;BR /&gt;
 &lt;BR /&gt;
I added the word "SAS" before the word "outputs", because that's how I read the sentence. What I don't understand is that IF SAS is creating the XLS spreadsheet -- how is it making the spreadsheet -- using ODS HTML, using PROC EXPORT, using CSV, using TAGSETS.EXCELXP?????? If you are using SAS to create the XML that you now want to turn around and edit, why not just change the SAS step to only contain the rows or turn off the borders??? &lt;BR /&gt;
&lt;BR /&gt;
Generally speaking SAS does not create an XLT file or populate an Excel template, it creates an ASCII text file that Excel can open (if you use ODS CSV, ODS HTML or ODS TAGSETS.EXCELXP). When SAS uses ODS, it does not ADD or REMOVE rows from a table or a spreadsheet -- it  recreates the file -- so you should be able to recreate the file. If you use PROC EXPORT, SAS might add a sheet to a workbook and then you might use an Excel template with the data in that workbook.&lt;BR /&gt;
 &lt;BR /&gt;
This is why I recommend that you contact Tech Support I think that altering the XML file might be above and beyond what you really need to do. And without seeing all of the code and the involved files, it's hard to make that determination or offer a meaningful suggestion here. I wouldn't recommend editing the XML until after you've investigated other options, especially if SAS is creating the XML file in the first place (the one you now want to edit).&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Tue, 06 Oct 2009 16:11:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74525#M16047</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-10-06T16:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete specific rows from an external file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74526#M16048</link>
      <description>Hi Curtis,&lt;BR /&gt;
&lt;BR /&gt;
Thanks a bunch for your reply. Yes thats exactly what I was looking for. But here's something interesting that I found. I tried to get the data into a dataset just to see what I get and only those &lt;CELL&gt; &lt;/CELL&gt; tags were stored that had data in them.&lt;BR /&gt;
&lt;BR /&gt;
But the most interesting part is when I tried the same data step as you suggested and tried to write to a file. I get the same # of lines as output as in the read file. Meaning unlike in the data step no rows were removed. &lt;BR /&gt;
&lt;BR /&gt;
I know its gotta be something simple. &lt;BR /&gt;
&lt;BR /&gt;
Many Thanks&lt;BR /&gt;
Jerry</description>
      <pubDate>Tue, 06 Oct 2009 18:17:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74526#M16048</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-10-06T18:17:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete specific rows from an external file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74527#M16049</link>
      <description>Hi Cynthia,&lt;BR /&gt;
&lt;BR /&gt;
I am given a pre-formatted excel sheet of 26 rows and 1396 columns where all cells from columns C - X have a financial formula in them. This template is not generated by SAS. &lt;BR /&gt;
&lt;BR /&gt;
So my goal is plug this template into a SAS process where the data extracted from a Data Step will be put into specific cells of the given template. Thus eliminating the need for the user to copy the results of the sas query and manually paste it into the excel template. &lt;BR /&gt;
&lt;BR /&gt;
I converted this pre-formatted excel spread sheet into excel xml form as template.xml and have sas read in the template file. &lt;BR /&gt;
&lt;BR /&gt;
Regards&lt;BR /&gt;
Jerry</description>
      <pubDate>Tue, 06 Oct 2009 18:23:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74527#M16049</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-10-06T18:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete specific rows from an external file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74528#M16050</link>
      <description>Jerry,&lt;BR /&gt;
&lt;BR /&gt;
I am glad it helped, but a bit confused with your reply.  Let me know if there was a question you needed answered, our if you were just sharing your experience.  I tested the code I sent you and the junk2.xml only had the rows I think you wanted.  If you change that _null_ to a dataset name, you will get results, but not what you were looking for.  The logic is based arround writting the correct results to the output file, but the dataset will be populated by the automatic output that occurs before the run statement.  If you want a dataset containing these results, you will need to put some explicit output statements along with the put statements, and put the results into a common variable.  Here is an example that generates the file and the dataset.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data JunkData(keep = outdata);&lt;BR /&gt;
  infile in lrecl=120;&lt;BR /&gt;
  file out lrecl=4000;&lt;BR /&gt;
  length CellHolder outdata $4000;&lt;BR /&gt;
  retain CellHolder;&lt;BR /&gt;
&lt;BR /&gt;
  input;&lt;BR /&gt;
&lt;BR /&gt;
  if _infile_ =: '&lt;CELL&gt;
     CellHolder = _infile_;&lt;BR /&gt;
  end;&lt;BR /&gt;
  if CellHolder = "" then do;&lt;BR /&gt;
    outdata = _infile_;&lt;BR /&gt;
    output;&lt;BR /&gt;
    put _infile_;&lt;BR /&gt;
  end;    &lt;BR /&gt;
  else do;&lt;BR /&gt;
    CellHolder = cats(CellHolder,_infile_);&lt;BR /&gt;
    if substr(CellHolder,length(CellHolder)-6) = '&lt;/CELL&gt;' then &lt;BR /&gt;
      do;&lt;BR /&gt;
        if index(CellHolder,"&amp;gt;") = 0 then do;&lt;BR /&gt;
          outdata = CellHolder;&lt;BR /&gt;
          output;&lt;BR /&gt;
          put CellHolder;&lt;BR /&gt;
        end;&lt;BR /&gt;
        CellHolder = "";&lt;BR /&gt;
      end;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 06 Oct 2009 18:42:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74528#M16050</guid>
      <dc:creator>CurtisMack</dc:creator>
      <dc:date>2009-10-06T18:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete specific rows from an external file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74529#M16051</link>
      <description>Hi Curtis, &lt;BR /&gt;
&lt;BR /&gt;
Thanks a bunch. The program is perfect when the raw datafile has now trailing blanks. but lets say if the rawdata reads:&lt;BR /&gt;
&lt;BR /&gt;
&lt;ROW&gt;&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;       &lt;CELL styleid="s77"&gt;&lt;DATA&gt;Cost of Goods &amp;nbsp;&amp;nbsp;&amp;nbsp; Sold&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;        &lt;CELL styleid="s77"&gt;&lt;/CELL&gt;&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;         &lt;CELL styleid="s76"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;           quot;,R[608]C)"&amp;gt;&lt;DATA&gt;&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;           &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;  &lt;BR /&gt;
&amp;nbsp; ss:Type="Number"&amp;gt;2285.4549999999999&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
&lt;/ROW&gt;&lt;BR /&gt;
&lt;BR /&gt;
I need to remove the trailing blank before letting sas read in the tags. Therefore in such an instance when I run the code the entire contents of the rawdata file is being put into the outfile. &lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Jerry

After the &lt;ROW&gt; tag there is a blank space for each occurrence of &lt;CELL .......=""&gt;&lt;/CELL&gt;&lt;/ROW&gt;&lt;BR /&gt;
&lt;BR /&gt;
    &lt;BR /&gt;
Message was edited by: jerry001</description>
      <pubDate>Wed, 07 Oct 2009 00:18:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74529#M16051</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-10-07T00:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete specific rows from an external file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74530#M16052</link>
      <description>Jerry,&lt;BR /&gt;
&lt;BR /&gt;
A simple STRIP function will solve most of what you are talking about:&lt;BR /&gt;
-------------------------------------------------------&lt;BR /&gt;
&lt;BR /&gt;
data JunkData(keep = outdata);&lt;BR /&gt;
  infile in lrecl=120;&lt;BR /&gt;
  file out lrecl=4000;&lt;BR /&gt;
  length CellHolder outdata InStr $4000;&lt;BR /&gt;
  retain CellHolder;&lt;BR /&gt;
&lt;BR /&gt;
  input;&lt;BR /&gt;
  InStr= strip(_infile_);&lt;BR /&gt;
&lt;BR /&gt;
  if strip(InStr) =: '&lt;CELL&gt;
     CellHolder = InStr;&lt;BR /&gt;
  end;&lt;BR /&gt;
  if CellHolder = "" then do;&lt;BR /&gt;
    outdata = InStr;&lt;BR /&gt;
    output;&lt;BR /&gt;
    put InStr;&lt;BR /&gt;
  end;    &lt;BR /&gt;
  else do;&lt;BR /&gt;
    CellHolder = cats(CellHolder,InStr);&lt;BR /&gt;
    if substr(CellHolder,length(CellHolder)-6) = '&lt;/CELL&gt;' then &lt;BR /&gt;
      do;&lt;BR /&gt;
        if index(CellHolder,"&amp;gt;") = 0 then do;&lt;BR /&gt;
          outdata = CellHolder;&lt;BR /&gt;
          output;&lt;BR /&gt;
          put CellHolder;&lt;BR /&gt;
        end;&lt;BR /&gt;
        CellHolder = "";&lt;BR /&gt;
      end;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
--------------------------------------------------------------&lt;BR /&gt;
&lt;BR /&gt;
but I never meant to imply that writting your own XML parser was going to be easy.  I have done it in the past, but it was not simple, and i had to assume a lot about how the XML would be structured in that particular process.  I only offered my solution because your example was so simple.  If for example you want to drop that line that reads "&lt;CELL styleid="s77"&gt;&lt;/CELL&gt;", you will need to add more logic to capture that condition and my code doesn't currently handle that last line of your new example.&lt;BR /&gt;
&lt;BR /&gt;
Good Luck,&lt;BR /&gt;
Curtis</description>
      <pubDate>Wed, 07 Oct 2009 00:54:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74530#M16052</guid>
      <dc:creator>CurtisMack</dc:creator>
      <dc:date>2009-10-07T00:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete specific rows from an external file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74531#M16053</link>
      <description>Hi Curtis, &lt;BR /&gt;
&lt;BR /&gt;
I admit.. this XML stuff is killing me. &lt;BR /&gt;
&lt;BR /&gt;
It wasn't until after I posted my reply did I realize that I could handle the spacing issue by applying a left trim. For the most part I have modified the code to get the desired result but I'm still faced with a major problem. &lt;BR /&gt;
&lt;BR /&gt;
After running the program in the outfile i get the following:&lt;BR /&gt;
&lt;BR /&gt;
&lt;ROW&gt;   &lt;BR /&gt;
&lt;CELL styleid="s77"&gt;&lt;DATA type="String"&gt;Cost of Goods Sold&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
&lt;CELL styleid="s77"&gt;&lt;/CELL&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
ss:Type="Number"&amp;gt;2285.4549999999999&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
ss:Type="Number"&amp;gt;2087.239&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
ss:Type="Number"&amp;gt;2082.4839999999999&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
ss:Type="Number"&amp;gt;2537.913&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
ss:Type="Number"&amp;gt;4086.61&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;/DATA&gt;   &lt;BR /&gt;
&lt;BR /&gt;
I'm not sure on how to get rid of the multiple repetitions of:&lt;BR /&gt;
&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;BR /&gt;
Below is my code:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
infile indata lrecl=1024;&lt;BR /&gt;
file outdata lrecl=4000;&lt;BR /&gt;
length CellHolder tag1 tag2 $4000;&lt;BR /&gt;
retain CellHolder tag1;&lt;BR /&gt;
&lt;BR /&gt;
putlog tag2;&lt;BR /&gt;
input;&lt;BR /&gt;
&lt;BR /&gt;
if _infile_ =: '&lt;CELL&gt;
CellHolder = _infile_;&lt;BR /&gt;
end;&lt;BR /&gt;
if CellHolder = "" then do;&lt;BR /&gt;
put _infile_;&lt;BR /&gt;
end; &lt;BR /&gt;
else do;&lt;BR /&gt;
*CellHolder = cats(CellHolder,_infile_);&lt;BR /&gt;
CellHolder = _infile_;&lt;BR /&gt;
if index(_infile_, '/&amp;gt;') &amp;gt; 0  then  do; tag1 = _infile_; put tag1;  end;&lt;BR /&gt;
if index(_infile_, 'ss:Formula=') &amp;gt; 0 then do; tag2 = _infile_; put tag2; tag2 = ""; end;  &lt;BR /&gt;
*put tag2;&lt;BR /&gt;
if substr(CellHolder,length(CellHolder)-6) = '&lt;/CELL&gt;' then&lt;BR /&gt;
do;&lt;BR /&gt;
if index(CellHolder,"&amp;gt;&lt;/DATA&gt;") = 0 then put CellHolder;&lt;BR /&gt;
CellHolder = "";&lt;BR /&gt;
end;&lt;BR /&gt;
end;&lt;BR /&gt;
run; &lt;BR /&gt;
&lt;BR /&gt;
I'm indeed so very grateful for your help.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Jerry&lt;/CELL&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/ROW&gt;</description>
      <pubDate>Wed, 07 Oct 2009 04:13:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74531#M16053</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-10-07T04:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete specific rows from an external file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74532#M16054</link>
      <description>Hi Curtis, &lt;BR /&gt;
&lt;BR /&gt;
I admit.. this XML stuff is killing me. &lt;BR /&gt;
&lt;BR /&gt;
It wasn't until after I posted my reply did I realize that I could handle the spacing issue by applying a left trim. For the most part I have modified the code to get the desired result but I'm still faced with a major problem. &lt;BR /&gt;
&lt;BR /&gt;
After running the program in the outfile i get the following:&lt;BR /&gt;
&lt;BR /&gt;
&lt;ROW&gt;   &lt;BR /&gt;
&lt;CELL styleid="s77"&gt;&lt;DATA type="String"&gt;Cost of Goods Sold&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
&lt;CELL styleid="s77"&gt;&lt;/CELL&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
ss:Type="Number"&amp;gt;2285.4549999999999&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
ss:Type="Number"&amp;gt;2087.239&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
ss:Type="Number"&amp;gt;2082.4839999999999&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
ss:Type="Number"&amp;gt;2537.913&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
ss:Type="Number"&amp;gt;4086.61&lt;/DATA&gt;&lt;/CELL&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;/DATA&gt;   &lt;BR /&gt;
&lt;BR /&gt;
I'm not sure on how to get rid of the multiple repetitions of:&lt;BR /&gt;
&lt;BR /&gt;
&lt;CELL styleid="s76" formula="=IF(R[608]C=&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,R[608]C)"&gt;&lt;DATA&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I'm indeed so very grateful for your help.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Jerry

Message was edited by: jerry001&lt;/DATA&gt;&lt;/CELL&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/DATA&gt;&lt;/CELL&gt;&lt;/ROW&gt;</description>
      <pubDate>Wed, 07 Oct 2009 04:15:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74532#M16054</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-10-07T04:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete specific rows from an external file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74533#M16055</link>
      <description>My original code had a flaw that worked fine in the original sample data, but not in this new sample.  The logic to concatinate the cell string needed to be in its own if block.  I think this will solve that last problem.&lt;BR /&gt;
------------------------------------------&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
  infile in lrecl=120;&lt;BR /&gt;
  file out lrecl=4000;&lt;BR /&gt;
  length CellHolder $4000;&lt;BR /&gt;
  retain CellHolder;&lt;BR /&gt;
&lt;BR /&gt;
  input;&lt;BR /&gt;
  if CellHolder ne "" then do;&lt;BR /&gt;
    CellHolder = catx(" ",CellHolder,_infile_);&lt;BR /&gt;
  end;&lt;BR /&gt;
  else if strip(_infile_) =: '&lt;CELL&gt;
     CellHolder = _infile_;&lt;BR /&gt;
  end;&lt;BR /&gt;
&lt;BR /&gt;
  if CellHolder = "" then do;&lt;BR /&gt;
    put _infile_;&lt;BR /&gt;
  end;    &lt;BR /&gt;
  else do;&lt;BR /&gt;
    if substr(CellHolder,length(CellHolder)-6) = '&lt;/CELL&gt;' then &lt;BR /&gt;
      do;&lt;BR /&gt;
        if index(CellHolder,"&amp;gt;") = 0 then do;&lt;BR /&gt;
          put CellHolder;&lt;BR /&gt;
        end;&lt;BR /&gt;
        CellHolder = "";&lt;BR /&gt;
      end;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
-----------------------------------------------------------&lt;BR /&gt;
&lt;BR /&gt;
Curtis</description>
      <pubDate>Wed, 07 Oct 2009 17:56:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74533#M16055</guid>
      <dc:creator>CurtisMack</dc:creator>
      <dc:date>2009-10-07T17:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete specific rows from an external file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74534#M16056</link>
      <description>One comment - you have no END=EOF condition for your INFILE, so on the last input record, is there going to be a pending PUT that needs to be executed because your DATA step will not iterate again?  Hopefully you are running some examples with either LIST; or PUTLOG _ALL_ / _INFILE_;  coded in your program.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 07 Oct 2009 21:10:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74534#M16056</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-10-07T21:10:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete specific rows from an external file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74535#M16057</link>
      <description>As I said earlier, this example assumes a lot about the structure of the XML.  If the &lt;CELL&gt; tags are at the begining of a record, and they are properly closed with a &lt;/CELL&gt; tag which falls at the end of a record, this code does work correctly.  Values are only retained if there is an open &lt;CELL&gt; tag.  All other lines are simply written out immediatly.  I did test it on the examples Jerry supplied, but admittedly was not attempting to write a complete XML parser.&lt;BR /&gt;
&lt;BR /&gt;
Curtis&lt;/CELL&gt;</description>
      <pubDate>Wed, 07 Oct 2009 21:50:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74535#M16057</guid>
      <dc:creator>CurtisMack</dc:creator>
      <dc:date>2009-10-07T21:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete specific rows from an external file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74536#M16058</link>
      <description>Hi Curtis, &lt;BR /&gt;
&lt;BR /&gt;
WOW!! This is soo awesome... you are amazing.. I just cant thank you enough..... Thanks a million for your help. &lt;BR /&gt;
&lt;BR /&gt;
Also, if I'm not troubling you, would you be kind enough to explain the logic to me.... In my initial code i had a similar flow.... but I just need to make sure that I understand the logic... &lt;BR /&gt;
&lt;BR /&gt;
Once again ...&lt;BR /&gt;
&lt;BR /&gt;
Many Many Many Thanks,&lt;BR /&gt;
Jerry</description>
      <pubDate>Thu, 08 Oct 2009 00:59:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74536#M16058</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-10-08T00:59:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete specific rows from an external file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74537#M16059</link>
      <description>Glad to be of help,&lt;BR /&gt;
&lt;BR /&gt;
The main difference between what I think your original code was doing and what this is doing, is that when the data step loop sees the begining of a &lt;CELL&gt; tag, it stores what it reads in the CellHolder variable untill it sees an &lt;/CELL&gt; tag.  When it sees the end, it only writes it out if there is not an empty &lt;DATA&gt; tag in the cell.  If the row has nothing to do with a tag, it just writes it out normally.  Here is a commented version of the last code I posted.&lt;BR /&gt;
--------------------------------------------------------&lt;BR /&gt;
data _null_;&lt;BR /&gt;
  infile in lrecl=120;&lt;BR /&gt;
  file out lrecl=4000;&lt;BR /&gt;
&lt;BR /&gt;
  * Prepare the varaible for storing CellTags.  This is where we will store the information &lt;BR /&gt;
    between a CELL open and CELL close tag;&lt;BR /&gt;
  length CellHolder $4000;&lt;BR /&gt;
  * Tell SAS to not clear the contents of CellHolder.  By default it will do this every time&lt;BR /&gt;
    it reads a new row from the input file;&lt;BR /&gt;
  retain CellHolder;&lt;BR /&gt;
&lt;BR /&gt;
  * Read a row from the input file;&lt;BR /&gt;
  input;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
  *If we have already seen an CELL tag but not its end (CellHolder already has something in it), &lt;BR /&gt;
   append the row we just read onto the end of the stored data; &lt;BR /&gt;
  if CellHolder ne "" then do;&lt;BR /&gt;
    CellHolder = catx(" ",CellHolder,_infile_);&lt;BR /&gt;
  end;&lt;BR /&gt;
  * Otherwise check to see if the row we just read is the start of a new CELL tag.  If so store the&lt;BR /&gt;
    row in CellHolder for later use;&lt;BR /&gt;
  else if strip(_infile_) =: '&lt;CELL&gt;
    CellHolder = _infile_;&lt;BR /&gt;
  end;&lt;BR /&gt;
&lt;BR /&gt;
  * If CellHolder is empty at this point, we know that the row we just read has nothing to do&lt;BR /&gt;
    with a CELL tag, so just write it out as it is;&lt;BR /&gt;
  if CellHolder = "" then do;&lt;BR /&gt;
    put _infile_;&lt;BR /&gt;
  end;&lt;BR /&gt;
  * Otherwise see if the CELL tag stores in CellHolder has a close tag at the end.  If so check to see&lt;BR /&gt;
    if it contains an empty DATA Tag.  If the DATA Tag is not empty, write the stored CELL tag to the&lt;BR /&gt;
    output file.  If not, do nothing.  In either case, empty the contents of CellHolder, because we are &lt;BR /&gt;
    done processing that tag; &lt;BR /&gt;
  else do;&lt;BR /&gt;
  if substr(CellHolder,length(CellHolder)-6) = '&lt;/CELL&gt;' then &lt;BR /&gt;
  do;&lt;BR /&gt;
  * Is the Data tag empty?;&lt;BR /&gt;
  if index(CellHolder,"&amp;gt;&lt;/DATA&gt;") = 0 then do;&lt;BR /&gt;
     *write the contents of CellHolder to the file;&lt;BR /&gt;
     put CellHolder;&lt;BR /&gt;
  end;&lt;BR /&gt;
  * Empty CellHolder;&lt;BR /&gt;
  CellHolder = "";&lt;BR /&gt;
  end;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;</description>
      <pubDate>Thu, 08 Oct 2009 01:54:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74537#M16059</guid>
      <dc:creator>CurtisMack</dc:creator>
      <dc:date>2009-10-08T01:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete specific rows from an external file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74538#M16060</link>
      <description>Curtis,&lt;BR /&gt;
&lt;BR /&gt;
Excellent. Thank you so much.... I'm so grateful for your help and once again thanks a million for taking the time to help me with this problem. &lt;BR /&gt;
&lt;BR /&gt;
I now have a clear understanding of the flow. In the beginning I kept missing the append string part. Now its all clear to me. &lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Jerry

Message was edited by: jerry001</description>
      <pubDate>Thu, 08 Oct 2009 12:16:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-specific-rows-from-an-external-file/m-p/74538#M16060</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-10-08T12:16:05Z</dc:date>
    </item>
  </channel>
</rss>

