The SAS Output Delivery System and reporting techniques

unexpected space with required quotation marks in xml file output

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 10
Accepted Solution

unexpected space with required quotation marks in xml file output

Generating a XML file in the datastep that acts as input for another program:

 

Filename outxml "C:\phase4.xml";

 

data _null_;
file outxml; /*XML Output File */
set testxml NOBS=Lst; /* SAS File with input data */
by fileName;

 if _n_=1 then do;

put '<?xml version="1.0" encoding="utf-8"?>';

end;

fileName= compress(fileName, );

put '<DataFile fileName="' fileName'" '; 

put 'dataCon="'  dataCon'" dataStdVer="' dataStdV'" dVersion="'   dVer'" />';

if _n_=lst then do;
put '</DataFile>';
end;
run;

 

 

Current output:

<?xml version="1.0" encoding="utf-8"?>

<DataFile fileName="test1.sas7bdat "

dataConformance="CDR1 " dataStandardVer="1 " domainVersion="1 " />

</DataFile>

 

 

All the variable are being resolved with a trailing space which is creating problem. While i checked the datafile, there are no trailing blanks, even the compress function is not helping. There seesm to be a problem with the quotation marks placement, if anyone can help me resolve this.

Thanks!


Accepted Solutions
Solution
‎05-30-2016 04:25 AM
Super User
Posts: 19,167

Re: unexpected space with required quotation marks in xml file output

That is the default behaviour of the put statement. Either build your string ahead of time using a CATT function or add +(-1) between your terms. 

 

Put var1 +(-1) var2;

View solution in original post


All Replies
Solution
‎05-30-2016 04:25 AM
Super User
Posts: 19,167

Re: unexpected space with required quotation marks in xml file output

That is the default behaviour of the put statement. Either build your string ahead of time using a CATT function or add +(-1) between your terms. 

 

Put var1 +(-1) var2;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 220 views
  • 0 likes
  • 2 in conversation