BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jacksonan123
Lapis Lazuli | Level 10
%splitby(NEWD,18);
run;


ods graphics /reset imagename='Final'
imagefmt=jpeg height=3 in width=6 in;
ods listing gpath= "/folders/myfolders/FITGRAPHS_CONC/" ;

%MACRO TEST;
%DO i=1% TO 34;

DATA NEWD&i;
SET WORK.FIT&i;
PROC SGPANEL DATA =NEWD&i;
PANELBY ID/columns=3  rows=2 ;

scatter x=TIME y=OBS;
series x=TIME y=CONC;
series x=TIME y=PRED /lineattrs=(color=red pattern=dash);
 run;	


RUN;
%end;
%mend TEST;
%TEST

The attached code was used to split a larger file into 34 smaller files to be plotted in SGPANEL. It runs okay.   The graph creates a  matrix of 3 columns and 2 rows.  The only problem is that a graph is in only one column while all the others are blank.  Can someone tell me how to get the code to populate all  6 panels? 

 

See an examples.Final.jpegFinal.jpeg

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

To use PROC SGPANEL, you do not need to break up the files or use a macro. You just give it the data and specify the size of each panel. Here is an example on some simulated data:

 

data Have;
do ID = 1 to 34;
   do i = 1 to 40;
      Time = rand("Normal");
      Pred = sin(Time);
      Obs = sin(Time) + rand("Normal", 0, 0.25);
      output;
   end;
end;
run;

proc sort data=Have;
   by ID Time;
run;

PROC SGPANEL DATA =Have;
   PANELBY ID/columns=3  rows=2 ;
   scatter x=TIME y=OBS;
   series x=TIME y=PRED;
run;	

View solution in original post

2 REPLIES 2
Rick_SAS
SAS Super FREQ

To use PROC SGPANEL, you do not need to break up the files or use a macro. You just give it the data and specify the size of each panel. Here is an example on some simulated data:

 

data Have;
do ID = 1 to 34;
   do i = 1 to 40;
      Time = rand("Normal");
      Pred = sin(Time);
      Obs = sin(Time) + rand("Normal", 0, 0.25);
      output;
   end;
end;
run;

proc sort data=Have;
   by ID Time;
run;

PROC SGPANEL DATA =Have;
   PANELBY ID/columns=3  rows=2 ;
   scatter x=TIME y=OBS;
   series x=TIME y=PRED;
run;	
jacksonan123
Lapis Lazuli | Level 10

Worked perfectly.  I didn't know that one did not have to split the data set just sort it for SGpanel.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 2 replies
  • 987 views
  • 0 likes
  • 2 in conversation