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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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