Dear all..
My motive is creating a login page simply & if user click submit button by entering correct credential then my choice macro [here in code it is "index page"] should run.
i have developed this code and it is working fine except my index_page macro output gets appended to the same page. i.e. _webout not clearing out previous contents.
i tried n ways options to close _webout but couldnt succeed. Any suggestions to the same code ? any other way to do the same?
kindly give your inputs. Thanks !
And yeah i have created stored process for this code where i have excluded stored process macros %stpbegin %stpend.
Code :
%MACRO LOGIN_PAGE;
data _null_;
file _webout;
PUT '<HTML>';
PUT '<HEAD> <TITLE> TITLE GOES HERE</TITLE>';
PUT '<STYLE>';
PUT 'BODY {COLOR:#d66a00; BACKGROUND:WHITE}';
PUT '.LOGIN_WINDOW { PADDING: 10PX;WIDTH:100PX;PADDING:30PX; COLOR:BLACK; background-color:WHITE; border: 3px solid LIGHTGREY;MARGIN:5em auto 0}';
PUT 'button { background-color: #a65200;color: white; border:none; cursor: pointer;width: 100PX;}';
PUT '</STYLE></HEAD>';
PUT'<BODY>';
PUT '<H1><CENTER> PAGE HEADING GOES HERE </H1> <BR>';
PUT '<form action='"&_URL"' method="POST">';
PUT '<INPUT TYPE="HIDDEN" NAME='"_PROGRAM"' VALUE='"&_PROGRAM"'>';
PUT '<div class="LOGIN_WINDOW">';
PUT '<label><b>Username</b></label><BR><input type="text" name="uname" required><BR><BR>';
PUT '<label><b>Password</b></label><BR><input type="password" name="psw" required><BR><BR>';
PUT '<button type="submit"><B>Login<B></button>';
PUT '</div>';
PUT '</FORM>';
PUT'</BODY>';
PUT'</HTML>';
RUN;
%MEND LOGIN_PAGE;
%MACRO INDEX_PAGE;
DATA _NULL_;
FILE _webout;
PUT '<HTML>';
PUT '<HEAD> <TITLE> INDEX PAGE </TITLE>';
PUT '<STYLE>';
PUT 'BODY {COLOR:#d66a00; BACKGROUND:WHITE}';
PUT '</STYLE>';
PUT'<BODY>';
PUT '<H1> <CENTER> WELCOME <CENTER> </H1> <BR>';
PUT'</BODY>';
PUT'</HTML>';
RUN;
%MEND INDEX_PAGE;
/*---------------EXECUTION SEQUENCE----------------*/
%MACRO MAIN;
%LOGIN_PAGE;
%IF "&UNAME"="HI" %THEN %INDEX_PAGE;
%MEND MAIN;
%MAIN;
Hi.
You just need to make sure that your "login_page" macro doesn't run if a username is submitted.
It could be something like
/*---------------EXECUTION SEQUENCE----------------*/ %MACRO MAIN; %IF "&UNAME"="HI" %THEN %INDEX_PAGE; %ELSE %LOGIN_PAGE; %MEND MAIN; %MAIN;
Its not working for me. Now its showing twice login page as else part is executing at initial pass.
This is working on my end in ordinary sas:
%global uname; %let uname=HI; %MACRO LOGIN_PAGE; %put Login_page; %MEND LOGIN_PAGE; %MACRO INDEX_PAGE; %put Index_page; %MEND INDEX_PAGE; /*---------------EXECUTION SEQUENCE----------------*/ %MACRO MAIN; %IF &UNAME eq HI %THEN %INDEX_PAGE; %else %login_page; %MEND MAIN; %MAIN;
Are you sure, that you are using the changed code in your stored process?
yeah .... still no success
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.