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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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