Hi. I have tried to make a Stored Process Application with, in this case, just three Parameters. The Application consists of three Stored Processes and two pages.
Page one has two radio buttons, and gives the user the option of pressing the "Next" button.
On page two the user may select a date from a roll down list, and may press one of these buttons: "PREVIOUS_PAGE", "HTML", "EXCEL" or "RESET".
If the user press one of these buttons, Stored Process #3 is excecuted. My intention is that, if the "PREVIOUS_PAGE" is pressed, the user should get page #1 on the screen. But it does'nt happen. Why?
The code from the different Stored processes is included.
Regards
Morten Fredrik Amundsen
The code for Stored process #1:
%global _ODSDEST _ODSSTYLE VALG DATO Bruker Resultat Type_Rapport User_ID Dato_Siste TYPE KUNDETYPE
SORTERING Kommentar AarMnd Dato2 _SECUREUSERNAME SECUREUSERNAME _STPNAME_E _LINK;
*ProcessBody;
/* Creates Dato2 */
%Let Dato2="&Dato."d;
%Put 'Dato:' &Dato.;
%Put 'Dato2:' &Dato2.;
/* Creates AarMnd */
%let AarMnd= %sysfunc(Year(&Dato2.))%sysfunc(Month(&Dato2.));
%macro PUTMENU_1;
/* Lager streng for &_program */
options urlencoding=utf8;
data _NULL;
length link $512.;
_LINK=urlencode("&_program._Print");
_LINK=tranwrd(_LINK,'%20','+');
_LINK=tranwrd(_LINK,'%C3%98','Ø');
_LINK='%nrstr(do?_program='!!strip(_LINK)!!')';
call symput('_LINK',_LINK);
put '_LINK:' &_LINK.;
run;
%put '_LINK:' &_LINK.;
/* First DATA _null_ step */
data _null_;
file _webout encoding='UTF-8';
put "<HTML>";
put "<h1 style=color:ForestGreen align=center> Internal accounts";
put "</h1>";
put "<div Align=Center>";
put "<body>";
put "<form ACTION='&_URL'>";
put "<input TYPE='HIDDEN' NAME='_action' value='form,properties,execute,nobanner,newwindow'>";
put "<input TYPE='hidden' NAME='_program' VALUE='/Landkreditt Bank Informasjonsplattform/Rapportering/Marked og IKT/Forretningsutvikling/Stored Process/StP-maler/Til SAS Community/Mal for xlsx_StP_P2'>";
put "<table BORDER=1 CELLSPACING=1 CELLPADDING=4 WIDTH='30%'>";
put "<tr>";
put "<td BGCOLOR='Yellow'>";
put "<input TYPE='RADIO' NAME='RappType' value='Last' checked>Last Period</input>" ;
put "<input TYPE='RADIO' NAME='RappType' VALUE='Daily'>Daily</input>";
put "</td>";
put "</tr>";
put "</table>";
run;
/*The last DATA _null_ step */
data _null_;
file _webout;
put "<input type='SUBMIT' name='valg' value='Next page'>";
put "</body></div></html>";
run;
%mend PUTMENU_1;
%PUTMENU_1;
The code for Stored Process #2:
%global _ODSDEST _ODSSTYLE VALG DATO Bruker Resultat Type_Rapport User_ID Dato_Siste
TYPE KUNDETYPE SORTERING Kommentar AarMnd Dato2 _SECUREUSERNAME SECUREUSERNAME _STPNAME_E _LINK RappType;
*ProcessBody;
%Let RappType = "&RappType";
/* Creates Dato2 */
%Let Dato2="&Dato."d;
%Put 'Dato:' &Dato.;
%Put 'Dato2:' &Dato2.;
/* Creates AarMnd */
%let AarMnd= %sysfunc(Year(&Dato2.))%sysfunc(Month(&Dato2.));
%macro PUTMENU;
/* Generates dates for prompt */
data work.DM_DIM_TID (keep=Dato_dt);
set mart.DM_DIM_TID;
Where Dato_DT >= intnx('month', Today(),-13) and
Dato_DT <= intnx('month', Today(),0) and
day(Dato_DT) = 1;
Run;
/* Sort descending */
Proc sort data=work.dm_dim_tid;
by Descending Dato_DT;
Run;
/* Insert the text "This mth." */
data work.dm_dim_tid;
set work.dm_dim_tid;
By descending dato_dt;
Length label $10;
/* First row */
If _N_ = 1 then do;
/* This month */
If Dato_dt = intnx('month',today(),0) then do;
Label = 'Denne mnd.';
End;
/* Previous months */
Else do;
Label = put(Dato_dt, date9.);
End;
End;
/* Other rows */
Else Do;
Label = put(Dato_dt, date9.);
End;
Run;
/* The first DATA _null_ step */
data _null_;
file _webout encoding='UTF-8';
put "<HTML>";
put "<h1 style=color:ForestGreen align=center> Internal Accounts";
put "</h1>";
put "<div Align=Center>";
put "<body>";
put "<form ACTION='&_URL'>";
put "<input TYPE='HIDDEN' NAME='_action' value='form,properties,execute,nobanner,newwindow'>";
put "<input TYPE='hidden' NAME='_program' VALUE='/Landkreditt Bank Informasjonsplattform/Rapportering/Marked og IKT/Forretningsutvikling/Stored Process/StP-maler/Til SAS Community/Mal for xlsx_StP_P3'>";
put "<table BORDER=1 CELLSPACING=1 CELLPADDING=4 WIDTH='30%'>";
put "<tr BGCOLOR='ForestGreen'>";
run;
/* The next DATA _null_ step */
/* Date */
data _null_;
file _webout;
set work.DM_DIM_TID;
if _N_ = 1 then do;
put "<td align=center valign=top WIDTH='30%'>";
put "<BR><font color=White size=3>Velg dato:</font></br>";
put "<select size=10 name='Dato'>";
put "<option value='" Dato_DT "' SELECTED>" Label "</option>";
end;
else do;
put "<option value='" Dato_DT "'>" Label "</option>";
end;
run;
/* The final DATA _null_ step */
data _null_;
file _webout;
put "</select>";
put "</tr></table>";
put "<input type='SUBMIT' name='valg' value='PREVIOUS_PAGE'>";
put "<input type='SUBMIT' name='valg' value='HTML'>";
put "<input type='SUBMIT' name='valg' value='EXCEL'>";
put "<input type='RESET' value='RESET'>";
put "</body></div></html>";
run;
%mend PUTMENU;
%PUTMENU;
The code for Stored Process #3:
%global _ODSDEST _ODSSTYLE VALG DATO Bruker Resultat Type_Rapport User_ID Dato_Siste
TYPE KUNDETYPE SORTERING Kommentar AarMnd Dato2 _SECUREUSERNAME SECUREUSERNAME _STPNAME_E _LINK RappType;
*ProcessBody;
/* Creates Dato2 */
%Let Dato2="&Dato."d;
%Put 'Dato:' &Dato.;
%Put 'Dato2:' &Dato2.;
/* Creates AarMnd */
%let AarMnd= %sysfunc(Year(&Dato2.))%sysfunc(Month(&Dato2.));
%Macro Funksjon;
%If %Upcase(&Valg) = PREVIOUS_PAGE %Then %do;
data _null_;
file _webout encoding='UTF-8';
put "<HTML>";
put "<Body>";
put "<form ACTION='&_URL'>";
put "<input TYPE='HIDDEN' NAME='_action' value='form,properties,execute,nobanner,newwindow'>";
put "<input TYPE='hidden' NAME='_program' VALUE='/Landkreditt Bank Informasjonsplattform/Rapportering/Marked og IKT/Forretningsutvikling/Stored Process/StP-maler/Til SAS Community/Mal for xlsx_StP_P1'>";
Put "</Body>";
Put "</HTML>";
Run;
%End;
%Mend;
%Funksjon;
I think it looks like you are submitting the same form regardless of which button is pressed.
You need different forms for each button. Maybe the javascript function onClick can help?
//Fredrik
Strange, but what happens if you replace the buttons with links to the stored process instead, just for testing I mean 🙂
//Fredrik
Hello again.
Are there someone who has made a Stored Process that let the user page forth and back?
Thanks. Regards Morten Fredrik
Morten,
If you hit 'View Source' for your blank 'previous page', what do you see?
<HTML>
<Body>
<form ACTION='/SASStoredProcess/do'>
<input TYPE='HIDDEN' NAME='_action' value='form,properties,execute,nobanner,newwindow'>
<input TYPE='hidden' NAME='_program' VALUE='/Landkreditt Bank Informasjonsplattform/Rapportering/Marked og IKT/Forretningsutvikling/Stored Process/StP-maler/Mal for xlsx_StP_P1'>
</Body>
</HTML>
Hi boemskats,
Thanks for your answer.
If I hit the 'View Source' on my blank 'previous screen', I see the code I have included in this message.
Thanks.
Morten Fredrik
Hi Morten,
So your stored process is working exactly as programmed. However,having read your first message I think you actually want to call your %PUTMENU macro when your PREVIOUS_PAGE condition is met?
%If %Upcase(&Valg) = PREVIOUS_PAGE %Then %do;
%PUTMENU;
%End;
The HTML you're currently outputting when the PREVIOUS_PAGE condition occurs does not display any visible elements, which is why you're seeing a blank page. There is no submit action to the form, so it just sits there, hidden. If you change your code to the above does your program work as you expected?
Otherwise, if you're actually wanting to reload the initial stored process screen on that PREVIOUS_PAGE condition (and I don't know why you would want to), consider something like this code:
%If %Upcase(&Valg) = PREVIOUS_PAGE %Then %do; data _null_; file _webout encoding='UTF-8'; put "<meta http-equiv="refresh" content="0; url=&_URL&_action=
form,properties,execute,nobanner,newwindow&_
_program=/Landkreditt Bank Informasjonsplattform/Rapportering/Marked og IKT/Forretningsutvikling/Stored Process/StP-maler/Til SAS Community/Mal for xlsx_StP_P1>";
Run;
%End;
This should force a clean refresh of your initial STP screen when the user hits the back button. However, again, I don't see why your program needs to call itself twice if the front screen drawing can be done inside the existing handler.
Nik
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.