goptions reset=all;

libname graphlib 'catalog-location';

data test;
input x y;
cards;
1 10
2 20
3 70
4 25
5 50
;
run;

data _null_;
   rc=gset('catalog','graphlib','graphcat');
   rc=ginit();

   call gask('numgraph',grseg_ct,rc);
   call symput('grseg_ct',grseg_ct);

   rc=gterm();
run;

%macro checkcat;
   %if &grseg_ct = 0 %then %do;
      proc gplot data=test gout=graphlib.graphcat; 
      plot y*x; 
      symbol1 i=j v=dot c=red; 
      run; 
      quit;
   %end;
   %else %do;
      proc greplay igout=graphlib.graphcat nofs;
      delete _all_; 
      run; 
      quit;
   %end;
%mend checkcat;

%checkcat