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!
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;
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;
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.
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.