Sample input data:
FirstName LastName Group Age LastVenue Position
Jack Smith ULDA 25 TheaterA 1
Jesse James GODL 37 TheaterB 12
Jane Doe ULDA 29 TheaterA 3
Izzy Gord IIPA 41 TheaterC 8
Ann Roswell GODL 30 TheaterB 16
Chelsea Jenk ULDA 19 TheaterA 11
I am trying to create:
%macro group_members(group=);
proc print data=sample;
var Position Age Group FirstName LastName;
where group=&group;
%mend group_members;
However I want to add conditions to it so if nothing is entered %group_members()
then it will display all groups with the order of the variables shown above. If an invalid group is entered in this case: %group_members(LOL)
then I would like a note to be sent to the log %put 'An invalid group was entered'
. and therefor nothing should be printed. I am trying to create a program very similar on a much larger dataset.
I appreciate any help in advanced! Thank you :)
So far I have tried:
%macro group_members(group=);
proc sql;
select count(*) into :ct
from sample
where group="&group"
quit;
proc print data=sample;
%if &group ^= %then %do;
where group="&group."; %end;
%if &ct = 0 %then %put An Invalid group was entered;
%else %do;
where group="&group.";
%end; run;
%mend group_members;
I get errors from every test.. for example %group_members()
returns an error of:
ERROR: More positional parameters found than defined