BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ChristosK
Quartz | Level 8

I've put this  figure together using this code but in the results windows, the keylegend displays the correct values but only as a column. Have tried running different across and down statements such as across =7 and down =1.

 

So tried instead the discrete legend.

ods listing close;
ods html style=mystyle path='.' file='newgraph.html';
ods graphics / reset=all border=off width=600 height=800  maxlegendarea=45 ;
   
   proc sgplot data=glm_MAP2 nowall noborder  ;

      title 'Linear Regression Models with Parameter estimates and SD for MAP';
      styleattrs datacontrastcolors=(CX016381 CX1BC9FF CXFF7F00 CX814101  ) ;

refline "mean Nex" "mean LA" "mean UA" "mean LL"/ discretethickness=1 lineattrs=(color=pink) axis=y;
hbarparm category=IV  response= Param / group =DV groupdisplay =cluster  grouporder=data 
barwidth=0.4  clusterwidth=1   limitupper=SD_Param    ;

yaxis type=discrete discreteorder=data label =".";
xaxis label ="."; 
discretelegend  / across=1 location=outside   noborder;  
yaxistable N rpIII  rParam rLCL 	rUCL/ VALUEATTRS=(Color=Black Family=Arial Size=7  Weight=Normal ) VALUEHALIGN=CENTER VALUEJUSTIFY= CENTER ;
 run;

 

This is the error I get for down=1:

NOTE: PROCEDURE SGPLOT used (Total process time):
       real time           0.38 seconds
       cpu time            0.20 seconds
       
 WARNING: DISCRETELEGEND statement with DISPLAYCLIPPED=FALSE is getting clipped. The legend will not be drawn.
 WARNING: DISCRETELEGEND statement with DISPLAYCLIPPED=FALSE is getting clipped. The legend will not be drawn.
 WARNING: The font <sans-serif> is not available. Albany AMT will be used.
 WARNING: DISCRETELEGEND statement with DISPLAYCLIPPED=FALSE is getting clipped. The legend will not be drawn.
 WARNING: The font <sans-serif> is not available. Albany AMT will be used.
 NOTE: There were 28 observations read from the data set USER.GLM_MAP2.
 
 92         
 93  OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

 

This is the error for Across=7:

 NOTE: PROCEDURE SGPLOT used (Total process time):
       real time           0.42 seconds
       cpu time            0.20 seconds
       
 WARNING: DISCRETELEGEND statement with DISPLAYCLIPPED=FALSE is getting clipped. The legend will not be drawn.
 WARNING: DISCRETELEGEND statement with DISPLAYCLIPPED=FALSE is getting clipped. The legend will not be drawn.
 WARNING: The font <sans-serif> is not available. Albany AMT will be used.
 WARNING: DISCRETELEGEND statement with DISPLAYCLIPPED=FALSE is getting clipped. The legend will not be drawn.
 WARNING: The font <sans-serif> is not available. Albany AMT will be used.
 NOTE: There were 28 observations read from the data set USER.GLM_MAP2.
 
 92         
 93         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

Since I am using a yaxis table, there may be a limited area to place the keylegend or dioscretelegend, although it worked fine when during my initial attempts with these axes transposed , with an x axis table and  vertical bands.

 

Is there something I can do with the ODS settings to allow this to work?

1 ACCEPTED SOLUTION

Accepted Solutions
JeffMeyers
Barite | Level 11

I used the TMPLOUT option in SGPLOT to get the template code for your graph, then moved the legend into the SIDEBAR block to allow it full range of the bottom of the graph. 

 

In GTL you can change the DISPLAYCLIPPED to be true so that the legend prints even if it is clipped.  However it was too wide with only one row so not all values were getting shown.  I instead changed DOWN=2 and it prints pretty nice.


    ods path WORK.TEMPLAT(UPDATE) SASHELP.TMPLMST (READ);
proc template;
define statgraph sgplot;
dynamic _NEGATIVE_;
dynamic _ticklist_;
begingraph / collation=binary dataContrastColors=( CX016381 CX1BC9FF CXFF7F00 CX814101 );
EntryTitle "Linear Regression Models with Parameter estimates and SD for MAP" /;
layout lattice / columnweights=preferred rowweights=preferred columndatarange=union rowdatarange=union columns=6;
    sidebar / align=bottom;
            DiscreteLegend "HBARPARM" / Location=Outside down=2 order=columnMajor Title="DV" Border=false displayclipped=true;
    endsidebar;
   layout overlay / walldisplay=none xaxisopts=( Label="." type=linear ) yaxisopts=( reverse=true Label="." type=discrete discreteopts=( sortOrder=data ) ) y2axisopts=(type=Discrete reverse=true discreteOpts=(tickValueList=_ticklist_ tickValueListPolicy=Union));
      ReferenceLine y= "mean Nex" / clip=true useDiscreteThickness=true discreteLineThickness=1 Lineattrs=( Color=CXFFC0CB);
      ReferenceLine y= "mean LA" / clip=true useDiscreteThickness=true discreteLineThickness=1 Lineattrs=( Color=CXFFC0CB);
      ReferenceLine y= "mean UA" / clip=true useDiscreteThickness=true discreteLineThickness=1 Lineattrs=( Color=CXFFC0CB);
      ReferenceLine y= "mean LL" / clip=true useDiscreteThickness=true discreteLineThickness=1 Lineattrs=( Color=CXFFC0CB);
      BarChartParm X=IV Y=Param / ErrorUpper=SD_Param primary=true orient=horizontal Group=DV barwidth=0.4 LegendLabel="Param" NAME="HBARPARM" groupdisplay=cluster grouporder=data clusterwidth=1;
  endlayout;
    Layout Overlay /  yaxisopts=( reverse=true Label="." type=discrete discreteopts=( sortOrder=data ) ) walldisplay=none yaxisopts=(display=none griddisplay=off displaySecondary=none) y2axisopts=(display=none griddisplay=off displaySecondary=none);
    AxisTable Value=N Y=IV / labelPosition=min ValueAttrs=( Color=CX000000 Size=7 Family="ARIAL" Weight=normal ) ValueHalign=Center ValueJustify=Center Display=(Label);
 endlayout;
 Layout Overlay /  yaxisopts=( reverse=true Label="." type=discrete discreteopts=( sortOrder=data ) ) walldisplay=none yaxisopts=(display=none griddisplay=off displaySecondary=none) y2axisopts=(display=none griddisplay=off displaySecondary=none);
 AxisTable Value=rpIII Y=IV / labelPosition=min ValueAttrs=( Color=CX000000 Size=7 Family="ARIAL" Weight=normal ) ValueHalign=Center ValueJustify=Center Display=(Label);
 endlayout;
 Layout Overlay /  yaxisopts=( reverse=true Label="." type=discrete discreteopts=( sortOrder=data ) ) walldisplay=none yaxisopts=(display=none griddisplay=off displaySecondary=none) y2axisopts=(display=none griddisplay=off displaySecondary=none);
 AxisTable Value=rParam Y=IV / labelPosition=min ValueAttrs=( Color=CX000000 Size=7 Family="ARIAL" Weight=normal ) ValueHalign=Center ValueJustify=Center Display=(Label);
 endlayout;
 Layout Overlay /  yaxisopts=( reverse=true Label="." type=discrete discreteopts=( sortOrder=data ) ) walldisplay=none yaxisopts=(display=none griddisplay=off displaySecondary=none) y2axisopts=(display=none griddisplay=off displaySecondary=none);
 AxisTable Value=rLCL Y=IV / labelPosition=min ValueAttrs=( Color=CX000000 Size=7 Family="ARIAL" Weight=normal ) ValueHalign=Center ValueJustify=Center Display=(Label);
 endlayout;
 Layout Overlay /  yaxisopts=( reverse=true Label="." type=discrete discreteopts=( sortOrder=data ) ) walldisplay=none yaxisopts=(display=none griddisplay=off displaySecondary=none) y2axisopts=(display=none griddisplay=off displaySecondary=none);
 AxisTable Value=rUCL Y=IV / labelPosition=min ValueAttrs=( Color=CX000000 Size=7 Family="ARIAL" Weight=normal ) ValueHalign=Center ValueJustify=Center Display=(Label);
 endlayout;
endlayout;
endgraph;
end;
run;
proc sgrender data=ibm.glm_map2 template=sgplot;
run;

SGRender.png

View solution in original post

9 REPLIES 9
ballardw
Super User

No data to test code against.

Also use of a custom STYLE may be having an impact that we cannot evaluate without the STYLE. Does the same thing happen when using other SAS styles such as HTMLBLUE?

 

 

You might also consider formatting the code with slightly shorter lines before posting to the forum. Extremely long lines are very difficult to deal with as the horizontal scroll is very cumbersome. Layout helps identify which options go with which statement as well. Something such as

ods listing close;
ods html style=mystyle path='.' file='newgraph.html';
ods graphics / reset=all border=off 
               width=600 height=800  
               maxlegendarea=45 
;
   
proc sgplot data=glm_MAP2 nowall noborder  ;

   title 'Linear Regression Models with Parameter estimates and SD for MAP';
   styleattrs datacontrastcolors=(CX016381 CX1BC9FF CXFF7F00 CX814101  ) ;

   refline "mean Nex" "mean LA" "mean UA" "mean LL"/ 
            discretethickness=1 
            lineattrs=(color=pink) 
            axis=y
   ;
   hbarparm category=IV  response= Param / 
            group =DV 
            groupdisplay =cluster  
            grouporder=data 
            barwidth=0.4  
            clusterwidth=1   
            limitupper=SD_Param    
   ;

   yaxis type=discrete discreteorder=data label =".";
   xaxis label ="."; 
   discretelegend  / across=1 location=outside   noborder;  
   yaxistable N rpIII  rParam rLCL 	rUCL/ 
      VALUEATTRS=(Color=Black Family=Arial Size=7  Weight=Normal ) 
      VALUEHALIGN=CENTER 
      VALUEJUSTIFY= CENTER
   ;
 run;

  

ChristosK
Quartz | Level 8

Data is attached.

 

Tried with HTMLBLUE, although I gave almost no knowledge of the options in ODS graphics.

 

Output looked the same.

 

Here is the error message:

 

 NOTE: ODS statements in the SAS Studio environment may disable some output features.
 73         
 74         
 75         ods listing close;
 76         ods html style=htmlblue;
 NOTE: Writing HTML Body file: sashtml10.htm
 ERROR: Insufficient authorization to access /opt/sasinside/SASConfig/Lev1/SASApp/sashtml10.htm.
 ERROR: No body file. HTML output will not be created.
 77         
 78         proc sgplot data=glm_MAP2 nowall noborder  ;
 79         
 80         title 'Linear Regression Models with Parameter estimates and SD for MAP';
 81             styleattrs datacontrastcolors=(CX016381 CX1BC9FF CXFF7F00 CX814101  ) ;
 82         
 83         refline "mean Nex" "mean LA" "mean UA" "mean LL"/
 84         discretethickness=1
 85         lineattrs=(color=pink)
 86         axis=y;
 87         
 88         hbarparm category=IV  response= Param /
 89         group =DV
 90         groupdisplay =cluster
 91         grouporder=data
 92         barwidth=0.4
 93         clusterwidth=1
 94         limitupper=SD_Param;
 95         
 96         yaxis type=discrete discreteorder=data label ="." ;
 97         xaxis label =".";
 98         discretelegend   /across=7  location=outside   noborder  ;
 99         yaxistable N rpIII  rParam rLCL rUCL/
 100        VALUEATTRS=(Color=Black Family=Arial Size=7  Weight=Normal )
 101        VALUEHALIGN=CENTER
 102        VALUEJUSTIFY= CENTER ;
 103         run;
 
 NOTE: PROCEDURE SGPLOT used (Total process time):
       real time           1.53 seconds
       cpu time            0.28 seconds
       
 WARNING: DISCRETELEGEND statement with DISPLAYCLIPPED=FALSE is getting clipped. The legend will not be drawn.
 WARNING: DISCRETELEGEND statement with DISPLAYCLIPPED=FALSE is getting clipped. The legend will not be drawn.
 NOTE: Some of the tick values have been thinned.
 WARNING: The font <sans-serif> is not available. Albany AMT will be used.
 WARNING: DISCRETELEGEND statement with DISPLAYCLIPPED=FALSE is getting clipped. The legend will not be drawn.
 WARNING: The font <sans-serif> is not available. Albany AMT will be used.
 NOTE: There were 28 observations read from the data set USER.GLM_MAP2.
 
 104        
 105        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
ChristosK
Quartz | Level 8

Here is the data:

 

I tried HTMLBLUE, although  I have almost no knowledge of the options in ODS Graophics.

 

Seemed to make no difference. Here is the error message:

 

 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 NOTE: ODS statements in the SAS Studio environment may disable some output features.
 73         
 74         
 75         ods listing close;
 76         ods html style=htmlblue;
 NOTE: Writing HTML Body file: sashtml10.htm
 ERROR: Insufficient authorization to access /opt/sasinside/SASConfig/Lev1/SASApp/sashtml10.htm.
 ERROR: No body file. HTML output will not be created.
 77         
 78         proc sgplot data=glm_MAP2 nowall noborder  ;
 79         
 80         title 'Linear Regression Models with Parameter estimates and SD for MAP';
 81             styleattrs datacontrastcolors=(CX016381 CX1BC9FF CXFF7F00 CX814101  ) ;
 82         
 83         refline "mean Nex" "mean LA" "mean UA" "mean LL"/
 84         discretethickness=1
 85         lineattrs=(color=pink)
 86         axis=y;
 87         
 88         hbarparm category=IV  response= Param /
 89         group =DV
 90         groupdisplay =cluster
 91         grouporder=data
 92         barwidth=0.4
 93         clusterwidth=1
 94         limitupper=SD_Param;
 95         
 96         yaxis type=discrete discreteorder=data label ="." ;
 97         xaxis label =".";
 98         discretelegend   /across=7  location=outside   noborder  ;
 99         yaxistable N rpIII  rParam rLCL rUCL/
 100        VALUEATTRS=(Color=Black Family=Arial Size=7  Weight=Normal )
 101        VALUEHALIGN=CENTER
 102        VALUEJUSTIFY= CENTER ;
 103         run;
 
 NOTE: PROCEDURE SGPLOT used (Total process time):
       real time           1.53 seconds
       cpu time            0.28 seconds
       
 WARNING: DISCRETELEGEND statement with DISPLAYCLIPPED=FALSE is getting clipped. The legend will not be drawn.
 WARNING: DISCRETELEGEND statement with DISPLAYCLIPPED=FALSE is getting clipped. The legend will not be drawn.
 NOTE: Some of the tick values have been thinned.
 WARNING: The font <sans-serif> is not available. Albany AMT will be used.
 WARNING: DISCRETELEGEND statement with DISPLAYCLIPPED=FALSE is getting clipped. The legend will not be drawn.
 WARNING: The font <sans-serif> is not available. Albany AMT will be used.
 NOTE: There were 28 observations read from the data set USER.GLM_MAP2.
JeffMeyers
Barite | Level 11

I used the TMPLOUT option in SGPLOT to get the template code for your graph, then moved the legend into the SIDEBAR block to allow it full range of the bottom of the graph. 

 

In GTL you can change the DISPLAYCLIPPED to be true so that the legend prints even if it is clipped.  However it was too wide with only one row so not all values were getting shown.  I instead changed DOWN=2 and it prints pretty nice.


    ods path WORK.TEMPLAT(UPDATE) SASHELP.TMPLMST (READ);
proc template;
define statgraph sgplot;
dynamic _NEGATIVE_;
dynamic _ticklist_;
begingraph / collation=binary dataContrastColors=( CX016381 CX1BC9FF CXFF7F00 CX814101 );
EntryTitle "Linear Regression Models with Parameter estimates and SD for MAP" /;
layout lattice / columnweights=preferred rowweights=preferred columndatarange=union rowdatarange=union columns=6;
    sidebar / align=bottom;
            DiscreteLegend "HBARPARM" / Location=Outside down=2 order=columnMajor Title="DV" Border=false displayclipped=true;
    endsidebar;
   layout overlay / walldisplay=none xaxisopts=( Label="." type=linear ) yaxisopts=( reverse=true Label="." type=discrete discreteopts=( sortOrder=data ) ) y2axisopts=(type=Discrete reverse=true discreteOpts=(tickValueList=_ticklist_ tickValueListPolicy=Union));
      ReferenceLine y= "mean Nex" / clip=true useDiscreteThickness=true discreteLineThickness=1 Lineattrs=( Color=CXFFC0CB);
      ReferenceLine y= "mean LA" / clip=true useDiscreteThickness=true discreteLineThickness=1 Lineattrs=( Color=CXFFC0CB);
      ReferenceLine y= "mean UA" / clip=true useDiscreteThickness=true discreteLineThickness=1 Lineattrs=( Color=CXFFC0CB);
      ReferenceLine y= "mean LL" / clip=true useDiscreteThickness=true discreteLineThickness=1 Lineattrs=( Color=CXFFC0CB);
      BarChartParm X=IV Y=Param / ErrorUpper=SD_Param primary=true orient=horizontal Group=DV barwidth=0.4 LegendLabel="Param" NAME="HBARPARM" groupdisplay=cluster grouporder=data clusterwidth=1;
  endlayout;
    Layout Overlay /  yaxisopts=( reverse=true Label="." type=discrete discreteopts=( sortOrder=data ) ) walldisplay=none yaxisopts=(display=none griddisplay=off displaySecondary=none) y2axisopts=(display=none griddisplay=off displaySecondary=none);
    AxisTable Value=N Y=IV / labelPosition=min ValueAttrs=( Color=CX000000 Size=7 Family="ARIAL" Weight=normal ) ValueHalign=Center ValueJustify=Center Display=(Label);
 endlayout;
 Layout Overlay /  yaxisopts=( reverse=true Label="." type=discrete discreteopts=( sortOrder=data ) ) walldisplay=none yaxisopts=(display=none griddisplay=off displaySecondary=none) y2axisopts=(display=none griddisplay=off displaySecondary=none);
 AxisTable Value=rpIII Y=IV / labelPosition=min ValueAttrs=( Color=CX000000 Size=7 Family="ARIAL" Weight=normal ) ValueHalign=Center ValueJustify=Center Display=(Label);
 endlayout;
 Layout Overlay /  yaxisopts=( reverse=true Label="." type=discrete discreteopts=( sortOrder=data ) ) walldisplay=none yaxisopts=(display=none griddisplay=off displaySecondary=none) y2axisopts=(display=none griddisplay=off displaySecondary=none);
 AxisTable Value=rParam Y=IV / labelPosition=min ValueAttrs=( Color=CX000000 Size=7 Family="ARIAL" Weight=normal ) ValueHalign=Center ValueJustify=Center Display=(Label);
 endlayout;
 Layout Overlay /  yaxisopts=( reverse=true Label="." type=discrete discreteopts=( sortOrder=data ) ) walldisplay=none yaxisopts=(display=none griddisplay=off displaySecondary=none) y2axisopts=(display=none griddisplay=off displaySecondary=none);
 AxisTable Value=rLCL Y=IV / labelPosition=min ValueAttrs=( Color=CX000000 Size=7 Family="ARIAL" Weight=normal ) ValueHalign=Center ValueJustify=Center Display=(Label);
 endlayout;
 Layout Overlay /  yaxisopts=( reverse=true Label="." type=discrete discreteopts=( sortOrder=data ) ) walldisplay=none yaxisopts=(display=none griddisplay=off displaySecondary=none) y2axisopts=(display=none griddisplay=off displaySecondary=none);
 AxisTable Value=rUCL Y=IV / labelPosition=min ValueAttrs=( Color=CX000000 Size=7 Family="ARIAL" Weight=normal ) ValueHalign=Center ValueJustify=Center Display=(Label);
 endlayout;
endlayout;
endgraph;
end;
run;
proc sgrender data=ibm.glm_map2 template=sgplot;
run;

SGRender.png

ChristosK
Quartz | Level 8

Jeff:

 

Thanks for that solution.

 

Only other things that would be use full would be:

 

1) Creating spaces between selected rows

2) Colour coding selected blocks (like the first 4 blue ones could have a background colour thats other than white.

 

Lots of new code options here that I have never seen before. Is there a source somewhere that explains these?

JeffMeyers
Barite | Level 11

Here is the reference for GTL in the newest SAS version: http://support.sas.com/documentation/cdl//en/grstatgraph/69718/HTML/default/viewer.htm#titlepage.htm

 

You can always output your SGPLOT to GTL with the TMPLOUT option to see what the background GTL code is.  It adds a lot of extraneous code, but isn't terrible.  

 

I tried to find solutions to your other two issues.  The code isn't as clean as I would like, but it potentially works.  The only way I could find to shade the backgrounds separately were to either use annotation (which is what I did) or to split each set of bars into it's own row and then color the backgrounds that way (more work potentially).

 

I had to change your axis to be linear and made a numeric Y variable.  I then spaced out bars by adding a blank row at a specific y value.

  
ods path WORK.TEMPLAT(UPDATE) SASHELP.TMPLMST (READ);
libname ibm '~/ibm/';
proc template;
define statgraph sgplot;
dynamic _NEGATIVE_;
dynamic _ticklist_;
begingraph / collation=binary dataContrastColors=( CX016381 CX1BC9FF CXFF7F00 CX814101 );
EntryTitle "Linear Regression Models with Parameter estimates and SD for MAP" /;
layout lattice / columnweights=preferred rowweights=preferred columndatarange=union rowdatarange=union columngutter=0 columns=7;
   
    sidebar / align=bottom;
            DiscreteLegend "HBARPARM" / Location=Outside down=2 order=columnMajor Title="DV" Border=false displayclipped=true;
    endsidebar;
    Layout Overlay /walldisplay=none yaxisopts=(reverse=true Label="." type=linear linearopts=(viewmin=0.5 viewmax=35) display=none);
      annotate / id="poly";
    AxisTable Value=iv Y=y / labelPosition=min ValueAttrs=( Color=CX000000 Size=7 Family="ARIAL" Weight=normal ) ValueHalign=Center ValueJustify=Center 
    Display=(values);
 endlayout;
   layout overlay / walldisplay=none xaxisopts=( display=(ticks tickvalues line) type=linear offsetmin=0 offsetmax=0) 
     yaxisopts=(reverse=true Label="." type=linear linearopts=(viewmin=0.5 viewmax=35) display=(line));
      annotate / id="poly";
      BarChartParm X=y Y=Param / ErrorUpper=SD_Param primary=true orient=horizontal Group=DV barwidth=0.4 LegendLabel="Param" NAME="HBARPARM" groupdisplay=cluster grouporder=data clusterwidth=1;
  endlayout;
    Layout Overlay / walldisplay=none  yaxisopts=(reverse=true Label="." type=linear linearopts=(viewmin=0.5 viewmax=35) display=none);
      annotate / id="poly";
    
      AxisTable Value=N Y=y / labelPosition=min ValueAttrs=( Color=CX000000 Size=7 Family="ARIAL" Weight=normal ) ValueHalign=Center ValueJustify=Center Display=(Label);
 endlayout;
 Layout Overlay / walldisplay=none yaxisopts=(reverse=true Label="." type=linear linearopts=(viewmin=0.5 viewmax=35) display=none);
      annotate / id="poly";
      AxisTable Value=rpIII Y=y / labelPosition=min ValueAttrs=( Color=CX000000 Size=7 Family="ARIAL" Weight=normal ) ValueHalign=Center ValueJustify=Center Display=(Label);
 endlayout;
 Layout Overlay / walldisplay=none yaxisopts=(reverse=true Label="." type=linear linearopts=(viewmin=0.5 viewmax=35) display=none);
      annotate / id="poly";
      AxisTable Value=rParam Y=y / labelPosition=min ValueAttrs=( Color=CX000000 Size=7 Family="ARIAL" Weight=normal ) ValueHalign=Center ValueJustify=Center Display=(Label);
 endlayout;

 Layout Overlay / walldisplay=none yaxisopts=(reverse=true Label="." type=linear linearopts=(viewmin=0.5 viewmax=35) display=none);
      annotate / id="poly";
      AxisTable Value=rLCL Y=y / labelPosition=min ValueAttrs=( Color=CX000000 Size=7 Family="ARIAL" Weight=normal ) ValueHalign=Center ValueJustify=Center Display=(Label);
 endlayout;
 Layout Overlay / walldisplay=none yaxisopts=(reverse=true Label="." type=linear linearopts=(viewmin=0.5 viewmax=35) display=none);
      annotate / id="poly";
      AxisTable Value=rUCL Y=y / labelPosition=min ValueAttrs=( Color=CX000000 Size=7 Family="ARIAL" Weight=normal ) ValueHalign=Center ValueJustify=Center Display=(Label);
 endlayout;
endlayout;
endgraph;
end;
run;


data plot anno (keep=dv iv y);
    set ibm.glm_map2;
    by notsorted dv;
    y+1;
    if first.dv then do;
        output anno;
    end;
    if last.dv then do;
        output anno plot;
        y=y+1;
        call missing(iv, rpIII,of param--sd_param,measure);
        output plot;
    end;
    else output plot;
run;
data annotate;
    set anno;
    by notsorted dv;
    array colors {10} $20. ('blue','red','green','purple','grey','tan','orange','silver','brown','darkred');
    length id function x1space y1space $50.;
    if first.dv then do;
        _count_+1;
        id='poly';fillcolor=colors(_count_);display='fill';layer='background';transparency=0.8;
        function='polygon';
        x1=0;y1=y-0.75;x1space='LAYOUTPERCENT';y1space='DATAVALUE';output;
        function='polycont';
        x1=100;output;
    end;
    else do;
        id='poly';fillcolor=colors(_count_);display='fill';layer='background';transparency=0.8;
        function='polycont';
        x1=100;y1=y+0.75;x1space='LAYOUTPERCENT';y1space='DATAVALUE';output;
        function='polycont';
        x1=0;output;
    end;
    drop dv iv;
run;
        
   ods graphics / reset height=8in;
proc sgrender data=plot template=sgplot sganno=annotate;
run;

 

SGRender.png

 

ChristosK
Quartz | Level 8

Second version works perfectly.

Have am error message on first one:

 

 

 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 NOTE: ODS statements in the SAS Studio environment may disable some output features.\

 

 

 110        end;
 NOTE: Overwriting existing template/link: SGPlot
 NOTE: STATGRAPH 'SGPlot' has been saved to: WORK.TEMPLAT
 111        run;
 NOTE: PROCEDURE TEMPLATE used (Total process time):
       real time           0.01 seconds
       cpu time            0.01 seconds
       
 
 112        proc sgrender data=Schumann.glm_MAP2; template=sgplot;
                                                  ________
                                                  180
 ERROR 180-322: Statement is not valid or it is used out of proper order.
 113        run;
 
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE SGRENDER used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 114        
 115        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 128        

 

Great stuff though.

 

Thanks again.

 

Christos

JeffMeyers
Barite | Level 11
For the error delete the semicolon between the data= and the template=. They both need to be apart of the PROC SGRENDER statement.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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