BookmarkSubscribeRSS Feed
Adrienne
Fluorite | Level 6

HI

 

I'm working on my first multi celled layout below in version 9.4 1M3 (Win7) and I'm having problems getting the text to be where I want. In the cell titled 'Summary Statistics' I'd like the table to be at the top of the cell and not in the center. And in the 'Quantiles' table I'd like to get the spacing between the lines to be smaller so all the data fits in the cell. The code is below the graph. Any suggestions? Thanks. (And yes, I'm trying to look like the JMP distribution output, which is popular here)

 

SGRender73.png

 

%let pctlv=0 0.5 2.5 25 50 75 90 97.5 99.5 100 ;


proc stdize data=sashelp.cars outstat=_pctls pctlpts= &pctlv. ;;
   var horsepower;
 run;

data _pctls;   
   length pctllab $10.;
   set _pctls;
   if _type_=: 'P';
   pctl=input(substr(translate(_type_,'.','_'),2),best12.);
   format pctl 6.1;
   select (pctl);
      when (100) pctllab='maximum';
      when (75) pctllab='quartile';
      when (50) pctllab='median';
      when (25) pctllab='quartile';
      when (0) pctllab='minimum';
      otherwise pctllab='';
   end;
run;

proc sort data=_pctls;
   by descending pctl;
run;

data _null_;
   set _pctls;
   i+1;
   ii=left(put(I,3.));
   CALL SYMPUT('pctl'||II,pctl);
   CALL SYMPUT('lpctl'||II,pctllab);
   CALL SYMPUT('vpctl'||II,horsepower);
   CALL SYMPUT('total',II);
RUN;


%macro cmplplot;

proc template;
   define statgraph sgdesign;
   dynamic _HORSEPOWER _WEIGHT ;
   begingraph;
      entrytitle halign=center 'Type in your title...';
      entryfootnote halign=left 'Type in your footnote...';
      layout lattice / rows=2 rowgutter=5
             rowweights=(0.6 0.4) ;
         rowaxes;
            rowaxis;
            rowaxis;
         endrowaxes;
         layout overlay / yaxisopts=( griddisplay=off);
            scatterplot x=_WEIGHT y=_HORSEPOWER / name='scatter';
         endlayout;
         layout lattice / columns=3 columngutter=2;
            cell;
               layout lattice / columndatarange=union rowweights=(preferred .8);
                  columnaxes;
                     columnaxis;
                     columnaxis;
                  endcolumnaxes;
                  layout overlay;
                     boxplot y=_HORSEPOWER / name='box(h)' orient=horizontal;
                  endlayout;
                  layout overlay;
                     histogram _HORSEPOWER / name='histogram' binaxis=false;
                  endlayout;
               endlayout;
            endcell;
            cell;
               cellheader;
                  layout gridded / border=true opaque=true
                    backgroundcolor=GraphAltBlock:color;
                    entry "Summary Statistics" / textattrs=(color=GraphFit:contrastColor);
                    endlayout;
               endcellheader;
               layout gridded/ columns=2  border=true autoalign=(topleft)
                                opaque=true backgroundcolor=GraphWalls:color;
                  entry halign=left "Mean"  ;       entry halign=left eval(strip(put(mean(horsepower),12.2)));
                  entry halign=left "Std Dev";      entry halign=left eval(strip(put(stddev(horsepower),12.2)));
                  entry halign=left "Std Err Mean"; entry halign=left eval(strip(put(stderr(horsepower),12.2)));
                  entry halign=left "N";            entry halign=left eval(strip(put(n(horsepower),12.0)));
               endlayout; 
            endcell;
            
            cell;
               cellheader;
                  layout gridded / border=true opaque=true
                    backgroundcolor=GraphAltBlock:color;
                    entry "Quantiles" / textattrs=(color=GraphFit:contrastColor);
                    endlayout;
               endcellheader;
               layout gridded / columns=3  border=true 
                             opaque=true backgroundcolor=GraphWalls:color;
               %do i=1 %to &total;
                  entry textattrs=(size=7) halign=left "&&pctl&i..%"; 
                     entry  textattrs=(size=7) halign=right "&&lpctl&i.."; 
                        entry  textattrs=(size=7) halign=left "&&vpctl&i..";
               %end;
               endlayout;
            endcell;
         endlayout;
      endlayout;
   endgraph;
   end;
run;
%mend cmplplot;
%cmplplot;

proc sgrender data=SASHELP.CARS template=sgdesign;
dynamic _HORSEPOWER="HORSEPOWER"  _WEIGHT="WEIGHT" ;
run;

 

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
  • 0 replies
  • 645 views
  • 0 likes
  • 1 in conversation