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

All,
    Wondering whats wrong in the open code that I am trying here: 

    The following works in a data step 

   

Data Test; 
	x1 = 'not a <tag>';
	x2 = htmldecode(x1);
Run; 

   
   However, when I move away from a datastep into open code, this fails(does not return an error, but does not have the desired impact. desired impact/result is demonstrated in data step): 

 

%Global x1 x2; 
%let x1 = 'not a <tag>';
%Put &x1;
%let x2 = htmldecode(&x1); 

   
  Can somebody kindly explain why ? The desired output is demonstrated in the data step. 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisBrooks
Ammonite | Level 13

The htmlencode function is a data step function. If you want this to work in open (or macro) code you need to wrap it inside a %sysfunc call e.g.

 

%Global x1 x2; 
%let x1 = 'not a <tag>';
%Put &x1;
%let x2 = %sysfunc(htmldecode(&x1));
%put &x2; 

You can find more details on how to use %sysfunc here -> http://support.sas.com/documentation/cdl/en/mcrolref/62978/HTML/default/viewer.htm#p1o13d7wb2zfcnn19...

View solution in original post

1 REPLY 1
ChrisBrooks
Ammonite | Level 13

The htmlencode function is a data step function. If you want this to work in open (or macro) code you need to wrap it inside a %sysfunc call e.g.

 

%Global x1 x2; 
%let x1 = 'not a <tag>';
%Put &x1;
%let x2 = %sysfunc(htmldecode(&x1));
%put &x2; 

You can find more details on how to use %sysfunc here -> http://support.sas.com/documentation/cdl/en/mcrolref/62978/HTML/default/viewer.htm#p1o13d7wb2zfcnn19...

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 993 views
  • 3 likes
  • 2 in conversation