I am having difficulties wth a macro loop that derives input from a prompt value. Below are my configurations:
SAS Enterprise Guide 7.1
Prompt:
Prompt Type: Text
Method for populating prompt: User enters values
Number of values: Multiple values
No minimums, maximums or default values entered
Prompt value is used throughout the project
The issue is that the code will fail if only one value is supplied to the prompt, if two or more are supplied the macro processes clean and produces the expected results. Additionally if you run the program with a single prompt value, run again with multiple values and then run again with a single prompt value the macro processes and produces the expected results. I am guessing that since I am not clearing the macro variables between runs this is why there are no errors in this instance. I need to be albe to execute this macro with one or more prompts supplied by the end user.
Below I have included an example of the macro loop I am attempting to create using the SASHELP.BASEBALL dataset and I have also included a log file export with the error message.
options symbolgen mlogic mfile ;
%macro LOOP_ia ;
%do i = 1 %to &DIV_COUNT. ;
proc sql ;
create table DIV_&&DIV&i. as
select Name
,Team
,Division
,Div
,League
,Position
from SASHELP.BASEBALL
where Division = propcase("&&DIV&i.")
order by Team, Name, Position
;
quit ;
%put &DIV. ;
%end ;
%mend LOOP_ia ;
%LOOP_ia ;
This an excerpt from the attached log file export.
MLOGIC(LOOP_IA): Beginning execution.
SYMBOLGEN: Macro variable DIV_COUNT resolves to 1
MLOGIC(LOOP_IA): %DO loop beginning; index variable I; start value is 1; stop value is 1; by value is 1.
SYMBOLGEN: && resolves to &.
SYMBOLGEN: Macro variable I resolves to 1
NOTE: Line generated by the macro variable "I".
48 DIV_&DIV1
_
22
200
WARNING: Apparent symbolic reference DIV1 not resolved.
SYMBOLGEN: && resolves to &.
SYMBOLGEN: Macro variable I resolves to 1
WARNING: Apparent symbolic reference DIV1 not resolved.
ERROR 22-322: Syntax error, expecting one of the following: (, '.', AS, LIKE.
ERROR 200-322: The symbol is not recognized and will be ignored.
... View more