Your SAS programs, embedded in web apps and elsewhere

Session Variable Dropped

Accepted Solution Solved
Reply
Super Contributor
Posts: 497
Accepted Solution

Session Variable Dropped

%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>";


Accepted Solutions
Solution
‎07-01-2015 02:43 PM
Super Contributor
Posts: 497

Re: Session Variable Dropped

Posted in reply to DavidPhillips2

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.

View solution in original post


All Replies
Regular Contributor
Posts: 217

Re: Session Variable Dropped

Posted in reply to DavidPhillips2

Is &save_insightsView a local macro variable?

Super Contributor
Posts: 497

Re: Session Variable Dropped

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.

Solution
‎07-01-2015 02:43 PM
Super Contributor
Posts: 497

Re: Session Variable Dropped

Posted in reply to DavidPhillips2

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.

Occasional Contributor
Posts: 8

Re: Session Variable Dropped

Posted in reply to DavidPhillips2

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.

Super Contributor
Posts: 497

Re: Session Variable Dropped

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(&currentPageName=)&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.

Occasional Contributor
Posts: 8

Re: Session Variable Dropped

Posted in reply to DavidPhillips2

Thank you David,

Your answer will help me decided which option is suitable for my scenario.

Thanks again.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 1230 views
  • 0 likes
  • 3 in conversation