Your SAS programs, embedded in web apps and elsewhere

Passing macro variable values with special characters within session using SAS stored processes

Reply
Contributor SGB
Contributor
Posts: 41

Passing macro variable values with special characters within session using SAS stored processes

Hi SAS-perts!

I have successfully created an UI using SAS Stored Processes in EG environment - Involving creating session, passing macro variables within a session, creating custom HTML forms, updating the form with user inputs, drill down reports-etc.

Thanks for the inputs from the SAS community as and when required. (Thanks to FriedEgg,  Filipvdr, milts, ballardw, NN, Juan Luis Sánchez Hernández.. Sorry If I missed anybody who helped me..Ofcourse SAS TechSupport)

My current problem is -

I have special characters in macro variable values. Initially I have suppressed '&' and apostrophe.

It is passing the 'comma' character properly. When I pass AAAA, INC - it is passing correctly.

But I realized that it is not passing the '+'.  When I pass 'days +3' and it ends up showing 'days 3'.

I m not sure what other special characters it will not pass!

Eventually I dont want to suppress any of the special characters and want to display them as such.

Examples.    The variable has the following values.. which is being passes as _name.

                         Wal&Mart

                        Wal-Mart

                        Wal'mart

                        Wal,Mart

Any help is appreciated!

Contributor
Posts: 22

Re: Passing macro variable values with special characters within session using SAS stored processes

Dear

did your read documentation about the function and call routine HTMLENCODE:

Encodes characters using HTML character entity references, and returns the encoded string.

Regards

Contributor SGB
Contributor
Posts: 41

Re: Passing macro variable values with special characters within session using SAS stored processes


Hi lacrefa

Thanks for your reply.

After posting this, I learnt that using URLENCODE is the one that I would need.

Thanks again!

Frequent Contributor
Posts: 148

Re: Passing macro variable values with special characters within session using SAS stored processes

If you are creating stored process server sessions, the other option is to take advantage of the SAVE_ convention for saving macro variables from one request to the next one. This only works if you are using sessions. Basically what the server does is at the end of the request, it saves all the macro variables whose name begin with SAVE_ (not case-sensitive) and then when a new request reconnects to the session, it loads the macro variables back so they are available. This is a nice way to save state without having to embed values in the URL as name/value pairs.

Ask a Question
Discussion stats
  • 3 replies
  • 444 views
  • 3 likes
  • 3 in conversation