BookmarkSubscribeRSS Feed
narayanjoshi7
Calcite | Level 5

Hi!! i was working on graph, i got sample code from sample graphs but somehow I am getting warning signs. The template I used -/* Define a macro that generates all style changes. */
%macro gdata;
%do i=1 %to &total;
&&gd&i
%end;
%mend gdata;
%let total=14;
/* Create the custom style. */
proc template;
define style styles.mystyle2;
parent=styles.default;
%gdata;
end;
run;  Kindly help. 

narayanjoshi7_0-1624392384486.png

 

4 REPLIES 4
ballardw
Super User

Most of the SAS supplied Styles only have 12 graphdata elements defined.

Your not shown code is apparently attempting to modify two graphdata elements that do not exist.

 

You would have to modify the code to create Graphdata13 and 14 from scratch and not modify them.

 

Large economy sized hint:

Text from the LOG should be copied and pasted into a text box opened on the forum with the </> icon.

Pictures can't be edited to make corrections or highlighted to show issues.

With MACRO code you should set Options mprint; before running the code and then show the entire generated code from the log. That way the warnings and such appear in context better and we can see what the heck was actually submitted to make better suggestions.

For example you show macro variables &total , that is not set where we can see a value, and apparently a whole bunch of other macro variables referenced with indirect references &&gd&i.

 

Us proc template with the LIST option to see the definition of the base style and you will see there is no style graphdata13 in Styles.Default. That listing should give you an idea on how to write Graphdata13 from scratch if actually needed.

 

FWIW, those are warnings. Your new style likely exists but it will not have Graphdata13 and 14 elements for use.

narayanjoshi7
Calcite | Level 5

proc sort data=ad1;
by subjid;
run;

/* Count the number of unique values of SUBJECT. */
/* Also create macro variables containing the */
/* style values for each plot line. The line */
/* color is based on the treatment group. */
data _null_;
set adqt1 end=eof;
by subjid;
if first.subjid then do;
if grn=1 then color='firebrick';
else if grn=2 then color='biy';
else if grn=3 then color='big' ;
else if grn=4 then color='bip';
count+1;
call symput('gd'||trim(left(count)),
'style '|| 'GraphData' || trim(left(count)) ||
' from GraphData' || trim(left(count)) ||
' / ContrastColor=' || trim(left(color)) ||
' linestyle=1;');
end;
if eof then call symput('total',count);
run;

/* Define a macro that generates all style changes. */
%macro gdata;
%do i=1 %to &total;
&&gd&i
%end;
%mend gdata;

/* Create the custom style. */
proc template;
define style styles.mystyle2;
parent=styles.default;
%gdata;
end;
run;

this is macro I am using for template.. Any suggestions ?

 

Reeza
Super User
What do you think that code is doing? What are you trying to do?
I see the template code, please show how you try and use it.
ballardw
Super User

@narayanjoshi7 wrote:

proc sort data=ad1;
by subjid;
run;

/* Count the number of unique values of SUBJECT. */
/* Also create macro variables containing the */
/* style values for each plot line. The line */
/* color is based on the treatment group. */
data _null_;
set adqt1 end=eof;
by subjid;
if first.subjid then do;
if grn=1 then color='firebrick';
else if grn=2 then color='biy';
else if grn=3 then color='big' ;
else if grn=4 then color='bip';
count+1;
call symput('gd'||trim(left(count)),
'style '|| 'GraphData' || trim(left(count)) ||
' from GraphData' || trim(left(count)) ||
' / ContrastColor=' || trim(left(color)) ||
' linestyle=1;');
end;
if eof then call symput('total',count);
run;

/* Define a macro that generates all style changes. */
%macro gdata;
%do i=1 %to &total;
&&gd&i
%end;
%mend gdata;

/* Create the custom style. */
proc template;
define style styles.mystyle2;
parent=styles.default;
%gdata;
end;
run;

this is macro I am using for template.. Any suggestions ?

 


Seriously flawed. I think you would be much better off not attempting to change a Style and instead look at the DATTRMAP option to create custom appearance for variables used as Group variables in procedures like SGPLOT and SGPANEL.

Much easier to manage, in my opinion, and would link the same Subjid to the same color, marker, line type. The graphdata elements assign the appearance based on order of appearance in a particular graphing procedure and hence the color/line/marker appearance can change based on order of data.

The DATTRMAP is a specially structured data set that has specific named variables to hold appearance options based on the value of something like Subjid. They would be much easier to add to than a Style, as you have found.

 

A brief example:  https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/grstatproc/p18q268a3zxcl3n11lnnnq4cme8r.htm

Documentation on the sets: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/grstatproc/n18szqcwir8q2nn10od9hhdh2ksj.htm

And a more complex example: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/grstatproc/n1sgstxp3pedkxn1tewmmgxccrqh.htm

 

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!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 725 views
  • 1 like
  • 3 in conversation