BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Leon27607
Fluorite | Level 6

@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....

Rick_SAS
SAS Super FREQ

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);
Leon27607
Fluorite | Level 6
OMG, I figured out the issue, I was missing a ")" at the end of my macro calling.
Rick_SAS
SAS Super FREQ

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
Fluorite | Level 6
Yeah noticed this too =/...
ballardw
Super User

@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

Rick_SAS
SAS Super FREQ

The lesson to learn for the future is ALWAYS post your SAS log. This would have been noticed immediately.

Leon27607
Fluorite | Level 6
The thing was... my log wasn't showing anything like I mentioned my SAS just "hung" there. The syntax error didn't show up unless I was trying to close my SAS application....
Rick_SAS
SAS Super FREQ

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.

Quentin
Super User

Additional lessons:

  1. Make a small amount of test data, and post it along with the code that shows the problem when run on the test data.
  2. Run your code on the test data in a fresh session.

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 ...

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
ballardw
Super User

@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.

SAS Innovate 2025: Register Now

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 25 replies
  • 4751 views
  • 6 likes
  • 7 in conversation