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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 605 views
  • 3 likes
  • 2 in conversation