Reputation: 135
I am using SAS Web Report Viewer where I have an interface from which end users can select the multiple values as an input to a macro variable. However, when I check the SAS Logs I see that only the first input value is passed on to the macro variable. How can I get all the values passed on to the macro variable? (And if possible separate the values using '|' as a delimiter). For example here I am trying to pass 'Discount_Logility' and 'Discount_EDD' as the inputs to the variable 'list_string' (I want the variable to dynamically take in more inputs depending on how many the user passes).
%put &list_string;
Here is the SAS Log
>>> SAS Macro Variables:
LIST_STRING=Discount_Logility
LIST_STRING0=2
LIST_STRING1=Discount_Logility
LIST_STRING2=Discount_EDD
LIST_STRING_COUNT=2
But here we can see that the macro variable 'list_string' takes only the first input, 'Discount_Logility'
21 +%put &list_string;
Discount_Logility
How can value of 'list_string' variable be list_string = Discount_Logility | Discount_EDD OR whatever be the best way to pass in the multiple inputs to the list_string variable.
Upvotes: 0
Views: 218
Reputation: 12909
SAS passes each one into its own macro variable. Note these three entries in the log:
LIST_STRING1=Discount_Logility
LIST_STRING2=Discount_EDD
LIST_STRING_COUNT=2
You can use LIST_STRING_COUNT
and iterate over all the selections.
%macro convert_to_list;
%global list_string;
%let list_string = &list_string1;
%do i = 2 %to &list_string_count.;
%let list_string = &list_string.|&&list_string&i.;
%end;
%mend;
%convert_to_list;
%put &list_string;
Discount_Logility|Discount_EDD
Upvotes: 1