BookmarkSubscribeRSS Feed
LOLO12
Obsidian | Level 7

Hi All, 

this macro dosn't work not sure what is the issue. 
%macro create_graph(_paramn=, _param=, _avision=, _trta=, _usubjid=);


data _null_;
set all;
where paramn=&_paramn. & param="&_param." & avision="&_avision." & trta="&_trta." & usubjid="&_usubjid.";
call symput('Int', put(intercept, BEST6.));
call symput('Slope', put(slope, BEST6.));
run;

proc sgplot data=all noautolegend;
where trta="&_trta." & usubjid="&_usubjid.";
title "Regression Line with Slope and Intercept";
reg y=aval x=accommodation_level;
inset "Intercept = &Int" "Slope = &Slope" /
border title="Parameter Estimates" position=topleft;
run;

%mend;


data test;
set all;
by paramn param avision trta usubjid NOTSORTED;
if first.usubjid then
do;
str=catt('%create_graph(_paramn=', paramn, ", _param=", param,
" , _avision=", avision, ", _trta= ", trta, ", _usubjid=", %str(usubjid),
');');
output;
end;
run;

 

3 REPLIES 3
tarheel13
Rhodochrosite | Level 12

what does the log say?

Tom
Super User Tom
Super User

You never call the macro in the code you posted.

You define a macro.

You create a dataset with a character variable that looks like perhaps it has the code to call the macro.  But you never run the code you put into the character variable.

 

 

Sajid01
Meteorite | Level 14

Hello @LOLO12 

Did you try the code before creating the macro?
Have a look at this blog post How to use PROC SGPLOT to display the slope and intercept of a regression line - The DO Loop (sas.co... 
This will help you understand using Proc SGPLOT do   what you want.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 3 replies
  • 1165 views
  • 2 likes
  • 4 in conversation