BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tom
Super User Tom
Super User

Ok. That is trivial.  No need for a MACRO.

So let's assume you have a control dataset and a list of selected items. You could then go through the data set and spit out which ones are selected.

data degree_list ;

  input code :$5. name $20.;

cards;

D Associate Degree

D1 Bachelor Degree

D2  Masters Degree

D3  Doctorate

;;;;

%let choice=D D1 D2 ;

data _null_;

  set degree_list ;

  if indexw("&choice",code) then put 'Has ' name ;

run;

Has Associate Degree

Has Bachelor Degree

Has Masters Degree

DavidPhillips2
Rhodochrosite | Level 12

I need the macro for 7 other dropdowns.

Tom
Super User Tom
Super User

Write the code to do one.  Then figure out how to make it flexible.

So if you have 7 different menus then your control data set needs another column to indicate which menu it is.

Tom
Super User Tom
Super User

if menu = "&menu_name" then put code name @;

if indexw("&choice",code) then put 'selected' @ ;

put ;

DavidPhillips2
Rhodochrosite | Level 12

I coded the dropdowns outside of the checkboxes a while back.  Both features are working.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 19 replies
  • 4847 views
  • 6 likes
  • 5 in conversation