I am building a stored process which begins with a custom HTML form where the user will select options with check boxes. After the check boxes are selected, or not selected, the user will hit "Submit" and the program will continue onto another program called "TestingFile."
The HTML code for the check boxes is:
<FORM ACTION="&_URL" method="post" enctype="multipart/form-data">
<INPUT TYPE="HIDDEN" NAME="_program" VALUE="/Shared Data/SAS Testing/TestingFile">
<INPUT TYPE="HIDDEN" NAME="submit" VALUE="submitted">
<td><p class="new2"><u><i>Sample Selection:</u></i></td>
<td><p class="portal">Option1</p></td>
<td><INPUT TYPE=CheckBox name="Opt1" Value="x"></td>
<td><p class="portal">Option2</p></td>
<td><INPUT TYPE=CheckBox name="Opt2" Value="x"></td>
<td><p class="portal">Option3</p></td>
<td><INPUT TYPE=CheckBox name="Opt3" Value="x"></td>
<td><p class="portal">Options4</p></td>
<td><INPUT TYPE=CheckBox name="Opt4" Value="x"></td>
</tr>
What I want to do is have the selections made by the user carry over to the program being called when the user selects "Submit". Do I need any other code to have the values of the options carried over, or will they carry over automatically? In my TestingFile program, which is called after the HTML form, I try to display what the values of the options are (whether or not they selected the options) but I can't seem to get any results. I tried to put the variables into a table and print the table, but the table comes out empty.
I'm just wondering if what I am doing is correct or if I am missing any information.
Thank you.
If the box is not checked, the browser does not generate a name-value pair from it.
-> in the HTML request, there will be no "opt2=x".
-> the Stored Process will not receive this parameter, there will be no macro variable with this name.
link:
To check for existence of a macro variable in SAS code:
%symexist(opt2)
Also look at this link:
I think your HTML form is almost OK.
Don't forget the start of the tr tag (<tr>), and to close the form (</form>)
First write a simple Stored Process:
%put &opt1.;
What do you see in the log? What URL do you see in the browser?
There are various ways to debug SPs. Look into the documentation of SP and Web Developers Guide.
Thank you for the suggestion. I was missing the <tr>. That seemed to get the %put &opt1; to work correctly.
I have been running this stored process in IE 10.
I tried to build on the simple stored process and check to see if the checkboxes were checked of not. I did some conditional if/then statements that if the variable did not equal 'x' then call it something else. If it was checked, and did have a value of 'x', use it in the %put statement.
This works fine when the box is checked, if the box is unchecked, I get the error message:
WARNING: Apparent symbolic reference Opt2 not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &Opt2 ^='x'
I have tried putting the single quotes around the 'x' as well as trying to use %bquote, but I can't seem to perform a check to see if the check box was checked by the user or not.
Any suggestions?
If the box is not checked, the browser does not generate a name-value pair from it.
-> in the HTML request, there will be no "opt2=x".
-> the Stored Process will not receive this parameter, there will be no macro variable with this name.
link:
To check for existence of a macro variable in SAS code:
%symexist(opt2)
Also look at this link:
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.