@Rick_SAS
The code you posted did work.... I don't know what SAS is doing but trying to use the plots macro like this DOESN'T work.
%plots(data2.inputdataremoved, choline_f2a, WRPM_ss, snp180, rs8016556_C(FDR=0.0403323974); although If i replace the macro variables with these exact names it works outside the macro....
Here is a macro call that does what you describe. If it works for you, then I suggest you check your data.
%Macro plots(data, cholinevar, response, SNP, title);
PROC sGPLOT DATA = &data noautolegend;
vbar &cholinevar._4 / response = &response stat = mean group = &SNP groupdisplay = cluster limitstat = stderr ;
title "&title";
run;
PROC sGPLOT DATA = &data noautolegend;
reg x = &cholinevar y = &response /group = &SNP clm ;
title "&title";
run;
%mend plots;
data class;
set sashelp.class;
age_4 = age;
run;
%plots(class, age, weight, sex, My Plot Title);
By the way, the code you posted has a syntax error:
%plots(data2.inputdataremoved, choline_f2a, WRPM_ss, snp180, rs8016556_C(FDR=0.0403323974);
Put an extra closing parenthesis before the semicolon.
@Leon27607 wrote:
@Rick_SAS
The code you posted did work.... I don't know what SAS is doing but trying to use the plots macro like this DOESN'T work.
%plots(data2.inputdataremoved, choline_f2a, WRPM_ss, snp180, rs8016556_C(FDR=0.0403323974); although If i replace the macro variables with these exact names it works outside the macro....
And there's the cause of the Macro parameter error that you saw. Per @Rick_SAS
The lesson to learn for the future is ALWAYS post your SAS log. This would have been noticed immediately.
We understand. The program "hangs" because the macro processor is waiting for those closing parentheses. I'm sure almost everyone on this thread has made this mistake before. Fortunately, after the first time, you know what to look for.
Additional lessons:
In this case, it was hard to help you because the code you posted was actually correct.
The main benefit of taking the time to make a simple test case with data and code is that it makes it easier for others to help you. A side benefit is that often as you make the simple test case, you will find a solution on your own. In this case, if you had run a simple test case, I would guess it would have worked, and then you would have looked back to see how your real code was different than your test code ...
@Rick_SAS wrote:
The lesson to learn for the future is ALWAYS post your SAS log. This would have been noticed immediately.
And the exact macro call used. Which resolved the question quickly.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.