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;
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.
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.
The hidden textbox should work. Currently doing a proof of concept.
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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.