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

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

1 ACCEPTED SOLUTION

Accepted Solutions
DavidPhillips2
Rhodochrosite | Level 12

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

6 REPLIES 6
jwillis
Quartz | Level 8

Is &save_insightsView a local macro variable?

DavidPhillips2
Rhodochrosite | Level 12

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.

DavidPhillips2
Rhodochrosite | Level 12

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.

Lokraj
Calcite | Level 5

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.

DavidPhillips2
Rhodochrosite | Level 12

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.

Lokraj
Calcite | Level 5

Thank you David,

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

Thanks again.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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