BookmarkSubscribeRSS Feed
subh
Calcite | Level 5

Hi,

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='Type:String'};
               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';
            run;
            ods tagsets.excelxp close;
            ods listing;

 

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

Thank You

6 REPLIES 6
ChrisNZ
Tourmaline | Level 20
subh
Calcite | Level 5
Its character K at the end of xml file
ballardw
Super User

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: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

ChrisNZ
Tourmaline | Level 20

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?

<note>
  <to>Rose</to>
  <from>Chris</from>
  <body>Don't forget me this weekend!</body>
</noteK>
subh
Calcite | Level 5

 

Hi,

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-com:office:spreadsheet"
          xmlns:x="urn:schemas-microsoft-com:office:excel"
          xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
          xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office">
---
---
<Row ss:AutoFitHeight="0" ss:StyleID="_body" ss:Height="14">
<Cell ss:StyleID="parskip"/>
--
--
<Cell ss:StyleID="data__l" ss:Index="16"><Data ss:Type="String">XXXXXXX</Data></Cell>
</Row>
</Table>
</Worksheet>
</Workbook>
k>

ChrisNZ
Tourmaline | Level 20

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;

  input;

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

run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1274 views
  • 0 likes
  • 3 in conversation