DATA Step, Macro, Functions and more

XML file opening issue

Occasional Contributor
Posts: 7

XML file opening issue


I am facing a strange issue.


our daily scheduled SAS job runs and creates XML file.

Sometimes due to some reason, xml file creates successfully, but not open.
xml files contains K> letter which causes error opening the output file.

When We manually run the same job again and we do not face this letter issue.

Below code is used to create output file:
options nocenter nodate missing = '';
            ods listing close;
            ods tagsets.excelxp file="&FOLDER_OUT..xml" style=newlist
                options(EMBEDDED_TITLES='yes' sheet_name='chk');

            proc print data=chkk noobs label sumlabel split='£'  ;
               var Product;
               var I002_number / style={tagattr='TypeSmiley Frustratedtring'};
               var I013_trxn_date I043a_merch_name;              
               var I005_amt_settle markupfee I028_trxn_fee I006_amt_bill
                   / style={TAGATTR='format:### ### ##0.00'};
               label Product = 'Product'
                     I002_number = 'Number'
                     I013_trxn_date = 'Date'
                     I043a_merch_name = 'Merchant name'
                     I005_amt_settle = 'Original'
                     markupfee = 'Mark up£fee'
                     I028_trxn_fee = '£fee'
                     I006_amt_bill = 'g£Amount'
               title1 'Chk';
            ods tagsets.excelxp close;
            ods listing;


Can anyone please help to let me know the solution of this issue.

Thank You

Super User
Posts: 2,518

Re: XML file opening issue

What's  K> letter   ?

Occasional Contributor
Posts: 7

Re: XML file opening issue

Its character K at the end of xml file
Super User
Posts: 13,950

Re: XML file opening issue

Can you provide a small example data set that duplicates this issue?

This link shows how to make data step code that we could use to test results:

Super User
Posts: 2,518

Re: XML file opening issue

So SAS inserts a K just before the very last character in the file, ie before the very last closing tag's closing bracket ?

Like this?

  <body>Don't forget me this weekend!</body>
Occasional Contributor
Posts: 7

Re: XML file opening issue



Character K> is comming at last of XML file and thats why file is not opening.

more strange to me is, this issue I face sometime(not often).

Also when I faced this issue , I tried to run again the same code and with same input (took historical date), then there is no problem and file generated absolutely fine. 


please find below(last line) where it is comming:


<?xml version="1.0" encoding="windows-1252"?>

<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-comSmiley Surprisedffice:spreadsheet"
          xmlns:x="urn:schemas-microsoft-comSmiley Surprisedffice:excel"
          xmlns:ss="urn:schemas-microsoft-comSmiley Surprisedffice:spreadsheet"
<DocumentProperties xmlns="urn:schemas-microsoft-comSmiley Surprisedffice">
<Row ss:AutoFitHeight="0" ssSmiley FrustratedtyleID="_body" ss:Height="14">
<Cell ssSmiley FrustratedtyleID="parskip"/>
<Cell ssSmiley FrustratedtyleID="data__l" ss:Index="16"><Data ss:Type="String">XXXXXXX</Data></Cell>

Super User
Posts: 2,518

Re: XML file opening issue

[ Edited ]

It looks like the last k of workbook is repeated, in other words the last 2 characters of the last line is repeated.


What I would do:


1- This looks like a bug, contact tech support.


2- To get the process going, and as a temporary workaround, I would add a data step in the process that reads the generated text file in a datestep after it's created and cleans the extraneous line if required.


data _null_;

  infile F sharebuffers end=LASTREC;

  file F;


  if LASTREC and _infile_ = 'k>' then put '  ';


Ask a Question
Discussion stats
  • 6 replies
  • 3 in conversation