Data visualization with SAS programming

Attribute Map Slows Box Plot with Medium Sized Data?

Reply
Trusted Advisor
Posts: 1,214

Attribute Map Slows Box Plot with Medium Sized Data?

Hi All,

 

I'm tearing apart a slow GTL boxplot (10-20 seconds on a 100,000 obs dataset) to see what parts are making it slow.  I'm using an attribute map to traffic-light it, and it seems that may be one contributor.  Running v9.3.

 

Below sample code I expand sashelp.prdsale into 144,000 obs, then run two SGRENDER steps to make box plots.  When I use the template with an attribute map, it takes 7 seconds, vs 1 second when there is no attribute map.  Interestingly, if I remove the /group option on the BOXPLOT statement, the time is the same.  So the time seems to be in the creation of the attribute map.

 

Does it make sense that building an attribute map would slow the SGRENDER step this much?  In my head the attribute map might only have 2 levels (red and black), but perhaps it ends up with 144,000?  

 

proc template;
  define statgraph BoxWithAttributeMap;
    begingraph;
      discreteattrmap name='AttrMapBox';
          value 'Red'    / fillattrs=(color=red) ;
          value 'Black'  / fillattrs=(color=lightgrey) ;
      enddiscreteattrmap;
      discreteattrvar 
        attrVar=AttrColorBox
        var=BoxColor
        attrmap='AttrMapBox' 
      ;
      layout overlay ;
        boxplot x=category y=actual /group=AttrColorBox ;
      endlayout; 
    endgraph;
  end;

  define statgraph BoxNoAttributeMap;
    begingraph;
      layout overlay ;
        boxplot x=category y=actual;
      endlayout; 
    endgraph;
  end;
run;

data prdsale;
  set sashelp.prdsale;
  category=catx('-',country,region,product);
  length BoxColor $10;
  if category='CANADA-EAST-BED' then BoxColor='Red';
  else BoxColor='Black';
  do i=1 to 100;
    output;
  end;
run;

proc sgrender data=prdsale template="BoxWithAttributeMap";
run;
proc sgrender data=prdsale template="BoxNoAttributeMap";
run;

 

 

Thanks,

--Q.

 

 

 

SAS Super FREQ
Posts: 1,081

Re: Attribute Map Slows Box Plot with Medium Sized Data?

Hi Quentin,

 

The experts here at SAS are looking into your use case, and have identified reasons for the slowdown.  This will be something we can address in the next release.

 

In the meantime, you could possibly work around the isue that is slowing this down..  Since you have a large data set, the parm data created for rendering contains not only the data for drawing the box, but also the original data set.  That is slowing down the internal process.  One way (similar to your previous question) would be to run the box plot WITHOUT the attr map setting and get the parm data (ODS OUTPUT).  Filter out the rows where STAT is missing.  Note, the STAT column name may have an internally generated long column name.

 

Now, run the GTL program with the AttrMap using BOXPLOTPARM and the new cleaned data set.  You will have to assign the internally generated long column names, including the one for group.  Use that for the group and the attrmap.  See if this helps.

 

 

Trusted Advisor
Posts: 1,214

Re: Attribute Map Slows Box Plot with Medium Sized Data?

Thanks @Sanjay_SAS, can definitely see how BOXPLOTPARM would help with this issue as well.  Really appreciate all your help on here (and your books and presentations and... )  I'll likely have more questions next week....

 

But have a great weekend!

Ask a Question
Discussion stats
  • 2 replies
  • 321 views
  • 1 like
  • 2 in conversation