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

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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