BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sAura
Fluorite | Level 6

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

1 REPLY 1
Reeza
Super User

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;

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
  • 1 reply
  • 753 views
  • 0 likes
  • 2 in conversation