%macro genslct(revdate=10/23/2023 2:31PM, /* This macro generates an HTML SELECT menu (SELECT and OPTION statements) based on a set of values and labels. These value-label combos can be specified in several ways: -- Specify a SAS dataset (&setin), a variable with the underlying code values (&valvar), and another with the corresponding label values to be displayed on the page (&labelvar). -- As above, but substitute the &valfmat parm for the labelvar. The labels that appear in the select are derived by using put(&valvar, $&valfmat.) -- Specify nothing except the &valfmat parm, referencing a permanent format code. The macro will use proc format with cntlout to generate the codes and value corresponding to the value-labels encapsulated in the format. -- For shorter lists, &values parm is a list of the underlying code values and the labels to be displayed for them. The form of this parm is values=%str(code=value code2=value2 ... ) John Blodgett, OSEDA, orginal code 3-2000. Major enhancements circa June, 2005. */ fileout = "select.html", /* Name of output file, or use _websas to pipe to browser if invoking from a browser using a SAS/IntrNet app. */ append = 0, /* append=1 adds output code onto the end of an existing file. */ setin = _last_, /* SAS dataset to be used for valvar and labelvar values. Ignored if values parm is specfied. */ setfilt = , /* Filter to be applied when reading setin (where clause without the where keyword). */ name = , /* Value of NAME attribute on the SELECT statement. */ size = , /* Value of the SIZE attribute on the SELECT statement. */ valvar = , /* Variable whose distinct values will be used to generate the OPTION entries. */ valpref = , /* String to be prepended to each value. Useful for when the values are complex URL strings. */ labelvar = , /* Variable used to generate the descriptive text to go with the OPTIONs. This is what the user selects to generate a value corresponding to the value of VALVAR. */ valfmat = , /* Can be specified instead of labelvar (if the latter has a value, valfmat will be ignored). This format will be used with values of valvar as the argument to generate the descriptive text for the OPTION entries. If setin is null (setin=,) then the value/label combinations will be generated via proc format with the cntlout parm to generate a list of args and formats. Include the $ for a character format. */ values = , /* Alternative to specifying valvar, labelvar. Values is a list of value=label specs separated by blanks, e.g., values=%str(1=Male 2=Female 3=Invalid). Do not use quotes. Quotes will be assumed for all args and values. Use underscores to represent blanks within values and labels, e.g., 7040=St._Louis_MSA. */ slctall = 0, /* Specify slctall=1 to generate the first OPTION entry as value ALL and have it selected. */ default = , /* Specify a value of valvar that is to have "SELECTED" specified for it. */ comment = , /* Insert HTML comment at head of output file. */ multiple = 1, /* Specify multiple=0 to omit the "mutliple" option on the SELECT statement. */ precode = , /* HTML code to insert just prior to the SELECT statement. Cannot contain double quotes. Use quoting function to enclose value. Use #amp instead of ampersands. */ postcode = , /* HTML code to insert following the select stmt. Cannot contain double quotes. */ sortby = , /* Normally the selections are in order by the code value (valvar). The only other option is the label variable. */ debug=0 /* [not implemented] */ ); %put ***** genslct macro, revised &revdate begin execution***** ; %if %superq(values) ne %str() %then %do; %* Generate the _valvars dataset by parsing the values parm which is of the form =