BookmarkSubscribeRSS Feed
JackieR
Calcite | Level 5

Good afternoon

I have a stored process which has a dropdown list that feeds off a table and displays one question at a time. 

I need to put a text box next to the drop down, but cannot get it to work properly. The drop down list displays on top instead of inside the drop down space (see image attached).

 

My original Code:


data _null_;
file _webout;
set onequestion_&i end=eof;
by Drop_Down_Selection;
if _n_=1 and Drop_Down_Selection not in ('Free text') then do;
put '<tr><td><table border=1 width=100%>';
put '<td class="TD2" width=100%>' questions '</td>';
put '<td colspan=1><select style="text-align: right" name="dropdowntp" id="dropdowntp">';
end;

if _n_=1 and Drop_Down_Selection in ('Free text') then do;
put '<tr><td><table border=1 width=100%>';

put '<td class="TD2" width=100%>' questions '</td>';

end;



if first.Drop_Down_Selection and Drop_Down_Selection not= 'Free text' then
if "&answer." = Drop_Down_Selection then
put '<option value="' Drop_Down_Selection '"' Drop_Down_Selection ' selected>' Drop_Down_Selection '</option>';
else
put '<option value="' Drop_Down_Selection '"' Drop_Down_Selection '>' Drop_Down_Selection '</option>';

if first.Drop_Down_Selection and Drop_Down_Selection = 'Free text' then
put '<td><input type="text" id="dropdowntp" name="dropdowntp" value='"&answer."'></td>';

if eof then do;
put '</select></td>';
put '</td></td></table>';
end;
run;

 

Changed code:


data _null_;
file _webout;
set onequestion_&i end=eof;
by Drop_Down_Selection;
if _n_=1 and Drop_Down_Selection not in ('Free text') then do;
put '<tr><td><table border=2 width=100%>';
put '<td class="TD2" width=100%>' questions '</td>';
put '<td colspan=1><select style="text-align: right" name="dropdowntp" id="dropdowntp">';
put '<td><input type="text" id="dropdownmul" name="dropdownmul" value='"&answer."'><tr></td>';

end;

if _n_=1 and Drop_Down_Selection in ('Free text') then do;
put '<tr><td><table border=1 width=100%>';
put '<td class="TD2" width=100%>' questions '</td>';
end;


if first.Drop_Down_Selection and Drop_Down_Selection not= 'Free text' then
if "&answer." = Drop_Down_Selection then do;
put '<td><option value="' Drop_Down_Selection '"' Drop_Down_Selection ' selected>' Drop_Down_Selection '</option>';
put '<input type="text" id="dropdownmul" name="dropdownmul" value='"thisone"'></td>';
end;

else do;
put '<option value="' Drop_Down_Selection '"' Drop_Down_Selection '>' Drop_Down_Selection '</option>';
end;

if first.Drop_Down_Selection and Drop_Down_Selection = 'Free text' then
put '<td><input type="text" id="dropdowntp" name="dropdowntp" value='"&answer."'></td>';

if eof then do;
put '</select></td>';
put '</td></td></table>';
end;

run;

1 REPLY 1
gamotte
Rhodochrosite | Level 12

Hello,

 

Sorry, your question is not clear at all.

 

Can you provide an example onequestion_&i dataset in the form of a data step (you can use the data2datastep macro linked at https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/).

Based on this example can you explain how the generated HTML differs from what you expects ?

 

Also, dont attach excel files to your question as many readers can't or won't open them. Use the camera icon to insert a picture instead.

camera.png

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1 reply
  • 510 views
  • 1 like
  • 2 in conversation