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

I’ve been researching how to integrate SAS and JavaScript.

Is there a way to set a SAS variable equal to JavaScript variable in SAS 9.2?  I have a stored process inside of Information Delivery Portal using a Web URL that displays a stored process inside a webpage like setup.  I found that SAS can use HTML variables when the user clicks refresh so long as the variables are Global Variables.  Changing the HTML variable changes the SAS variable. I want to access one of the Global variables via JavaScript so that I can reference the value when the page reloads. I only need the JavaScript to extract the value of:

$(""#degStudLev"").multipleSelect('getSelects');

Is there a way extract this value as html or assign it to a Global SAS variable?

The code concept is:

%Global degStudLev degStudLevComma;


/*degStudLev is assigned a value*/

%macro javaScriptFunctions;

            data _null_ ;

             file _webout ;

             put '<script type="text/JavaScript">' ;

            put "function saveMultiSelection() {";

                        put "alert('Selected values: ' + $(""#degStudLev"").multipleSelect('getSelects'));";

/*this is the line doesn't save the variable back to SAS Global Variable degStudLevComma.*/

                        put "var degStudLevComma = $(""#degStudLev"").multipleSelect('getSelects');";

            put "}";

%mend;

%javaScriptFunctions;

1 ACCEPTED SOLUTION

Accepted Solutions
BrunoSilva
Quartz | Level 8

If the multiple selection is a List Box when you submit the form it is converted to multiple macro variables in SAS.

If not a List Box, how about you save to a hidden text input, when your form is submited you get the value on SAS as a macro variable.

View solution in original post

3 REPLIES 3
BrunoSilva
Quartz | Level 8

If the multiple selection is a List Box when you submit the form it is converted to multiple macro variables in SAS.

If not a List Box, how about you save to a hidden text input, when your form is submited you get the value on SAS as a macro variable.

DavidPhillips2
Rhodochrosite | Level 12

The hidden textbox should work.  Currently doing a proof of concept.

BrunoSilva
Quartz | Level 8

How about using HttpRequestObject (Ajax) to interact with SAS and using Sessions to keep the Variable Value between interactions?

See links bellow with the puzzle parts:

https://support.sas.com/resources/papers/proceedings10/014-2010.pdf

SAS Stored Processes: Sessions

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1800 views
  • 0 likes
  • 2 in conversation