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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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