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

i am trying below code but special characters are not display in browser.

 

data transformed_data;
input DC_01 $6. DC_02 $13. DC_03 $9.;
cards;
116312 tosst p%o&ic
118323 tosst Police Mobile
113244 tosst Police Mobile
115333 tosst Police Mobile
118333 tosst Police Mobile
;
run;

data _null_;
set transformed_data;
file "$FSAGQS/QIS_DIBIS/transfers2/TEST_Shan1.xml";
if _n_=1 then do;
put '<?xml version="1.0" encoding="iso-8859-1"?>';
put '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:type="http://www.quinity.com/qis/soap/qisxmlpolicyrequestservice/type">';
Put '<Data>';
put '<answer>';
put '<value>' DC_01 '</value>';
put '</answer>';
put '<answer>';
put '<value>' DC_02 '</value>';
put '</answer>';
Put '</Data>';
end;
run;

Thank You.

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Onyx | Level 15

Hi, maybe try encode the characters:

data transformed_data;
input DC_01 $6. DC_02 $13. DC_03 $9.;
cards;
116312 tosst p%o&ic
118323 tosst Police Mobile
113244 tosst Police Mobile
115333 tosst Police Mobile
118333 tosst Police Mobile
;
run;

data _null_;
set transformed_data;
file "C:\Users\bart\Desktop/TEST_Shan1.xml";
if _n_=1 then do;
put '<?xml version="1.0" encoding="iso-8859-1"?>';
put '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:type="http://www.quinity.com/qis/soap/qisxmlpolicyrequestservice/type">';
end;
Put '<Data>';
put '<answer>';
put '<value>' DC_01 '</value>';
put '</answer>';
put '<answer>';

DC_02x = HTMLENCODE(DC_02);

put '<value>' DC_02x '</value>';
put '</answer>';
Put '</Data>';
run;

Bart

 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

6 REPLIES 6
yabwon
Onyx | Level 15

Hi, maybe try encode the characters:

data transformed_data;
input DC_01 $6. DC_02 $13. DC_03 $9.;
cards;
116312 tosst p%o&ic
118323 tosst Police Mobile
113244 tosst Police Mobile
115333 tosst Police Mobile
118333 tosst Police Mobile
;
run;

data _null_;
set transformed_data;
file "C:\Users\bart\Desktop/TEST_Shan1.xml";
if _n_=1 then do;
put '<?xml version="1.0" encoding="iso-8859-1"?>';
put '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:type="http://www.quinity.com/qis/soap/qisxmlpolicyrequestservice/type">';
end;
Put '<Data>';
put '<answer>';
put '<value>' DC_01 '</value>';
put '</answer>';
put '<answer>';

DC_02x = HTMLENCODE(DC_02);

put '<value>' DC_02x '</value>';
put '</answer>';
Put '</Data>';
run;

Bart

 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Shantaram
Calcite | Level 5
Thank you so much Yabwon,
Its working.
s_lassen
Meteorite | Level 14

One possibility is to use the CDATA section marker:

 

data _null_;
set transformed_data;
file "$FSAGQS/QIS_DIBIS/transfers2/TEST_Shan1.xml";
if _n_=1 then do;
put '<?xml version="1.0" encoding="iso-8859-1"?>';
put '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:type="http://www.quinity.com/qis/soap/qisxmlpolicyrequestservice/type">';
Put '<Data>';
put '<answer>';
put '<value><![CDATA[' DC_01 ']]></value>';
put '</answer>';
put '<answer>';
put '<value><![CDATA[' DC_02' ]]></value>';
put '</answer>';
Put '</Data>';
end;
run;

This way, unless your columns contain the string "]]>", they will be shown faithfully.

 

Shantaram
Calcite | Level 5
Thanks s_lassen,

Its working but it will add extra line in the output
like <![CDATA
]]
I don't want to add extra line in to the output.
Shantaram
Calcite | Level 5

Please help me to solve this issue.

without using CDATA how we can display special characters like %$& etc. in any browser.

 

 

Thanks.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 6 replies
  • 1386 views
  • 3 likes
  • 3 in conversation