%let rc=%sysfunc(stpsrv_session(create));
%Global save_insightsView;
I have a Web URL portlet displaying a SAS stored process. When the user clicks the refresh button the session variables are kept. When the user clicks the link with this code the variable save_insightsView is dropped. Any idea on why it is dropped or how I can keep the variable?
PUT "<a href=&SERVER/"@;
PUT "SASPortal/Director?_directive="@;
PUT "STPRun&_action=execute%nrstr(&_program)=%SYSFUNC(URLENCODE(&_PROGRAM))>"@;
link text</a>";
I tried this too.
PUT "<a href=&SERVER/"@;
PUT "SASPortal/Director?_directive="@;
PUT "STPRun&_action=execute%nrstr(&_program)=%SYSFUNC(URLENCODE(&_PROGRAM))"@;
PUT "%nrstr(&save_insightsView)=&save_insightsView)>"@;
PUT "link text</a>";
I did a crazy work around where I used the session variable when I was not sending to Excel and used another variable when sending to Excel. It seems that when the page reloaded and used the content type of Excel that my session variables were not accessed.
Is &save_insightsView a local macro variable?
It is a session variable
If you use
%let rc=%sysfunc(stpsrv_session(create));
And place save_ in front of a variable it is a session variable.
I did a crazy work around where I used the session variable when I was not sending to Excel and used another variable when sending to Excel. It seems that when the page reloaded and used the content type of Excel that my session variables were not accessed.
Hello David,
I have similar requirements. I need to pass user selection from one stored process to another STP. I am using session to achieve that.
In the first STP, user select term(eg. Fall2013). Here is the code I use.
%global save_term;
%let rc = %sysfunc(stpsrv_session(create));
%let save_term=whatever user selects;
Now, my question is, how you retrieve the value of save_term in second STP?.
Thanks for your help.
Lokraj,
With some of the session stuff I just used what works, theoretically a session variable should be open from one stored process to another if SAS properly coded it as session, but I found a lot of bugs with session programming. Even though I used sessions for one thing, if it didn’t work as expected I used a work around for another.
You could try appending to the URL like.
PUT "<a href=&SERVER/"@;
PUT "SASPortal/Director?_directive="@;
PUT "STPRun&_action=execute%nrstr(&_program)=%SYSFUNC(URLENCODE(&_PROGRAM))"@;
PUT "%nrstr(&FORMAT=EXCEL)%nrstr(¤tPageName=)&save_insightsView"@;
Then using the variable sent in the URL.
A third option that I found I had to use sometimes was invisible textboxes.
I have about four posts on these where I asked questions about similar items and posted the solution for the exact issue.
Thank you David,
Your answer will help me decided which option is suitable for my scenario.
Thanks again.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.