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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 759 views
  • 0 likes
  • 2 in conversation