Learning SAS? Welcome to the exclusive online community for all SAS learners.

Can one access the template editor from SAS University Edition?

Accepted Solution Solved
Reply
PROC Star
Posts: 7,364
Accepted Solution

Can one access the template editor from SAS University Edition?

Can one access the template editor from SAS University Edition? I am trying to find out if there is a way to eliminate the Number of Observations line that prints above a correlation matrix resulting from proc corr. Regardless, I'd like to know how one can peruse the various templates that are used for any proc. I already know how to turn ods trace on, and edit the templates shown as a result, but I can't find where the chart titles are defined.

 


Accepted Solutions
Solution
‎02-28-2017 11:50 AM
SAS Super FREQ
Posts: 8,744

Re: Can one access the template editor from SAS University Edition?

HI, 

Typically, for the SAS/STAT procedures, the ODS Table names and information about ODS GRAPHICS objects are shown in the procedure documentation, such as here for PROC CORR:

http://support.sas.com/documentation/cdl/en/procstat/70116/HTML/default/viewer.htm#procstat_corr_toc...

and as shown in the highlighted section:

PROC_CORR_doc.png

 

As you can see in the doc, the name of the object is the PearsonCorr table object created by the base.corr.StackedMatrix table template.

 

  I am not sure what template editor you are referencing. If you mean the Style Editor, then the answer is no. But what I do to review the template and all the various inheritance that is at work, is run this code once I know the name of the template:

proc template;
  source base.corr.stackedmatrix/file='c:\temp\stackmtx.txt';
run;

which gives me the ability to figure out what's going on with the template.

 

  The handy thing about the template code is that it shows exactly where you look in the template list to find the template of interest, as shown in the log:

log_template.png

So, instead of looking in SASHELP.TMPLMST, I could look in SASHELP.TMPLBASE, but in fact, I now have the full code for the Stacked Matrix template in the TXT file.

 

  In looking at the Base.Corr.StackedMatrix table template definition,

define table Base.Corr.Stackedmatrix;
   notes "Default CORR stacked matrix";
   column (RowName RowLabel) (Matrix) * (Matrix2) * (Matrix3) * (Matrix4);
   translate _val_=._ into "";

   define RowName;
      varname = Variable;
      parent = Common.Column.RowName;
   end;

   define RowLabel;
      varname = Label;
      parent = Common.Column.RowLabel;
   end;
   parent = common.stackedmatrix;
   split_stack = OFF;
end;

it looks to me like the headers are coming from the parent template, which is common.stackedmatrix:

proc template;                                                                
   define table Common.StackedMatrix;                                         
      notes "Stacked Matrix template definition.";                            
      dynamic ul ol spill space split csplit id csmin csmax newpage ts rs     
         cmwidth cmxwidth;                                                    
      column (rowname rowlabel) (matrix) * (matrix2) * (matrix3) * (matrix4) *
         (matrix5) * (matrix6) * (matrix7) * (matrix8) * (matrix9);           
      header head;                                                            
                                                                              
      define head;                                                            
         parent = common.header.matrix;                                       
      end;                                                                    
                                                                              
      define rowname;                                                         
         parent = common.column.rowname;                                      
      end;                                                                    
                                                                              
      define rowlabel;                                                        
         parent = common.column.rowlabel;                                     
      end;                                                                    
                                                                              
      define matrix;                                                          
         parent = common.column.matrix;                                       
      end;  
. . . more code . . . 

so here is common.header.matrix (all of it):

proc template;                                                                
   define header Common.Header.Matrix;                                        
      notes "Default matrix header";                                          
      dynamic header_text split space spill;                                  
      text header_text;                                                       
      space = space;                                                          
      split = split;                                                          
      spill_margin = spill;                                                   
   end;                                                                       
run;  

where you finally see that the header_text, is dynamic -- which means that PROC CORR sends its internally coded headers directly to the table template at the point in time when the analysis is created. I am not sure whether it's even possible to get rid of the N= on the first header line. That would be something I would ask of Tech Support. Or, I would use ODS OUTPUT to make an output table and then massage the output table and write it out with PROC REPORT.  Mostly I would use PROC REPORT because I don't like messing with Table templates that are used by the procedures.

 

  Something like this:

 

*------------------- Fish Measurement Data ----------------------*
| The data set contains 35 fish from the species Bream caught in |
| Finland's lake Laengelmavesi with the following measurements:  |
| Weight   (in grams)                                            |
| Length3  (length from the nose to the end of its tail, in cm)  |
| HtPct    (max height, as percentage of Length3)                |
| WidthPct (max width,  as percentage of Length3)                |
*----------------------------------------------------------------*;
title; footnote;
  
data Fish1 (drop=HtPct WidthPct);
   title 'Fish Measurement Data';
   input Weight Length3 HtPct WidthPct @@;
   Weight3= Weight**(1/3);
   Height=HtPct*Length3/100;
   Width=WidthPct*Length3/100;
   datalines;
242.0 30.0 38.4 13.4     290.0 31.2 40.0 13.8
340.0 31.1 39.8 15.1     363.0 33.5 38.0 13.3
430.0 34.0 36.6 15.1     450.0 34.7 39.2 14.2
500.0 34.5 41.1 15.3     390.0 35.0 36.2 13.4
450.0 35.1 39.9 13.8     500.0 36.2 39.3 13.7
475.0 36.2 39.4 14.1     500.0 36.2 39.7 13.3
500.0 36.4 37.8 12.0        .  37.3 37.3 13.6
600.0 37.2 40.2 13.9     600.0 37.2 41.5 15.0
700.0 38.3 38.8 13.8     700.0 38.5 38.8 13.5
610.0 38.6 40.5 13.3     650.0 38.7 37.4 14.8
575.0 39.5 38.3 14.1     685.0 39.2 40.8 13.7
620.0 39.7 39.1 13.3     680.0 40.6 38.1 15.1
700.0 40.5 40.1 13.8     725.0 40.9 40.0 14.8
720.0 40.6 40.3 15.0     714.0 41.5 39.8 14.1
850.0 41.6 40.6 14.9    1000.0 42.6 44.5 15.5
920.0 44.1 40.9 14.3     955.0 44.0 41.1 14.3
925.0 45.3 41.4 14.9     975.0 45.9 40.6 14.7
950.0 46.5 37.9 13.7
;
run;

ods trace on / label;
ods graphics on / reset=all height=4in width=6in;
title 'Fish Measurement Data';
ods output PearsonCorr=work.pcorr;
proc corr data=fish1 nomiss alpha plots=matrix;
   var Weight3 Length3 Height Width;
run;
ods trace off;

proc print data=work.pcorr;
run;


data work.newcorr;
  length ncw3 ncl3 ncht ncwd $100;
  format newcorr $100.;
  set work.pcorr;
  ordvar = _n_;
    ncw3 = catx('^{newline 1}',put(Weight3,7.5),put(pweight3, pvalue8.4));
    ncl3 = catx('^{newline 1}',put(Length3,7.5),put(plength3, pvalue8.4));
    ncht = catx('^{newline 1}',put(Height,7.5),put(pheight, pvalue8.4));
    ncwd = catx('^{newline 1}',put(Width,7.5),put(pwidth, pvalue8.4));
run;

title 'Work.Newcorr';
ods escapechar='^';
proc report data=work.newcorr;
  column ordvar ("Pearson Correlation Coefficients" variable ncw3 ncl3 ncht ncwd);
  define ordvar / order noprint;
  define variable / display ' ' style(column)=Header;
  define ncw3 / 'Weight3' style(column)={just=r};
  define ncl3 / 'Length3' style(column)={just=r};
  define ncht / 'Height' style(column)={just=r};
  define ncwd / 'Width' style(column)={just=r};
run;


Hope this helps,

 

cynthia

View solution in original post


All Replies
Solution
‎02-28-2017 11:50 AM
SAS Super FREQ
Posts: 8,744

Re: Can one access the template editor from SAS University Edition?

HI, 

Typically, for the SAS/STAT procedures, the ODS Table names and information about ODS GRAPHICS objects are shown in the procedure documentation, such as here for PROC CORR:

http://support.sas.com/documentation/cdl/en/procstat/70116/HTML/default/viewer.htm#procstat_corr_toc...

and as shown in the highlighted section:

PROC_CORR_doc.png

 

As you can see in the doc, the name of the object is the PearsonCorr table object created by the base.corr.StackedMatrix table template.

 

  I am not sure what template editor you are referencing. If you mean the Style Editor, then the answer is no. But what I do to review the template and all the various inheritance that is at work, is run this code once I know the name of the template:

proc template;
  source base.corr.stackedmatrix/file='c:\temp\stackmtx.txt';
run;

which gives me the ability to figure out what's going on with the template.

 

  The handy thing about the template code is that it shows exactly where you look in the template list to find the template of interest, as shown in the log:

log_template.png

So, instead of looking in SASHELP.TMPLMST, I could look in SASHELP.TMPLBASE, but in fact, I now have the full code for the Stacked Matrix template in the TXT file.

 

  In looking at the Base.Corr.StackedMatrix table template definition,

define table Base.Corr.Stackedmatrix;
   notes "Default CORR stacked matrix";
   column (RowName RowLabel) (Matrix) * (Matrix2) * (Matrix3) * (Matrix4);
   translate _val_=._ into "";

   define RowName;
      varname = Variable;
      parent = Common.Column.RowName;
   end;

   define RowLabel;
      varname = Label;
      parent = Common.Column.RowLabel;
   end;
   parent = common.stackedmatrix;
   split_stack = OFF;
end;

it looks to me like the headers are coming from the parent template, which is common.stackedmatrix:

proc template;                                                                
   define table Common.StackedMatrix;                                         
      notes "Stacked Matrix template definition.";                            
      dynamic ul ol spill space split csplit id csmin csmax newpage ts rs     
         cmwidth cmxwidth;                                                    
      column (rowname rowlabel) (matrix) * (matrix2) * (matrix3) * (matrix4) *
         (matrix5) * (matrix6) * (matrix7) * (matrix8) * (matrix9);           
      header head;                                                            
                                                                              
      define head;                                                            
         parent = common.header.matrix;                                       
      end;                                                                    
                                                                              
      define rowname;                                                         
         parent = common.column.rowname;                                      
      end;                                                                    
                                                                              
      define rowlabel;                                                        
         parent = common.column.rowlabel;                                     
      end;                                                                    
                                                                              
      define matrix;                                                          
         parent = common.column.matrix;                                       
      end;  
. . . more code . . . 

so here is common.header.matrix (all of it):

proc template;                                                                
   define header Common.Header.Matrix;                                        
      notes "Default matrix header";                                          
      dynamic header_text split space spill;                                  
      text header_text;                                                       
      space = space;                                                          
      split = split;                                                          
      spill_margin = spill;                                                   
   end;                                                                       
run;  

where you finally see that the header_text, is dynamic -- which means that PROC CORR sends its internally coded headers directly to the table template at the point in time when the analysis is created. I am not sure whether it's even possible to get rid of the N= on the first header line. That would be something I would ask of Tech Support. Or, I would use ODS OUTPUT to make an output table and then massage the output table and write it out with PROC REPORT.  Mostly I would use PROC REPORT because I don't like messing with Table templates that are used by the procedures.

 

  Something like this:

 

*------------------- Fish Measurement Data ----------------------*
| The data set contains 35 fish from the species Bream caught in |
| Finland's lake Laengelmavesi with the following measurements:  |
| Weight   (in grams)                                            |
| Length3  (length from the nose to the end of its tail, in cm)  |
| HtPct    (max height, as percentage of Length3)                |
| WidthPct (max width,  as percentage of Length3)                |
*----------------------------------------------------------------*;
title; footnote;
  
data Fish1 (drop=HtPct WidthPct);
   title 'Fish Measurement Data';
   input Weight Length3 HtPct WidthPct @@;
   Weight3= Weight**(1/3);
   Height=HtPct*Length3/100;
   Width=WidthPct*Length3/100;
   datalines;
242.0 30.0 38.4 13.4     290.0 31.2 40.0 13.8
340.0 31.1 39.8 15.1     363.0 33.5 38.0 13.3
430.0 34.0 36.6 15.1     450.0 34.7 39.2 14.2
500.0 34.5 41.1 15.3     390.0 35.0 36.2 13.4
450.0 35.1 39.9 13.8     500.0 36.2 39.3 13.7
475.0 36.2 39.4 14.1     500.0 36.2 39.7 13.3
500.0 36.4 37.8 12.0        .  37.3 37.3 13.6
600.0 37.2 40.2 13.9     600.0 37.2 41.5 15.0
700.0 38.3 38.8 13.8     700.0 38.5 38.8 13.5
610.0 38.6 40.5 13.3     650.0 38.7 37.4 14.8
575.0 39.5 38.3 14.1     685.0 39.2 40.8 13.7
620.0 39.7 39.1 13.3     680.0 40.6 38.1 15.1
700.0 40.5 40.1 13.8     725.0 40.9 40.0 14.8
720.0 40.6 40.3 15.0     714.0 41.5 39.8 14.1
850.0 41.6 40.6 14.9    1000.0 42.6 44.5 15.5
920.0 44.1 40.9 14.3     955.0 44.0 41.1 14.3
925.0 45.3 41.4 14.9     975.0 45.9 40.6 14.7
950.0 46.5 37.9 13.7
;
run;

ods trace on / label;
ods graphics on / reset=all height=4in width=6in;
title 'Fish Measurement Data';
ods output PearsonCorr=work.pcorr;
proc corr data=fish1 nomiss alpha plots=matrix;
   var Weight3 Length3 Height Width;
run;
ods trace off;

proc print data=work.pcorr;
run;


data work.newcorr;
  length ncw3 ncl3 ncht ncwd $100;
  format newcorr $100.;
  set work.pcorr;
  ordvar = _n_;
    ncw3 = catx('^{newline 1}',put(Weight3,7.5),put(pweight3, pvalue8.4));
    ncl3 = catx('^{newline 1}',put(Length3,7.5),put(plength3, pvalue8.4));
    ncht = catx('^{newline 1}',put(Height,7.5),put(pheight, pvalue8.4));
    ncwd = catx('^{newline 1}',put(Width,7.5),put(pwidth, pvalue8.4));
run;

title 'Work.Newcorr';
ods escapechar='^';
proc report data=work.newcorr;
  column ordvar ("Pearson Correlation Coefficients" variable ncw3 ncl3 ncht ncwd);
  define ordvar / order noprint;
  define variable / display ' ' style(column)=Header;
  define ncw3 / 'Weight3' style(column)={just=r};
  define ncl3 / 'Length3' style(column)={just=r};
  define ncht / 'Height' style(column)={just=r};
  define ncwd / 'Width' style(column)={just=r};
run;


Hope this helps,

 

cynthia

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 218 views
  • 1 like
  • 2 in conversation