The SAS Output Delivery System and reporting techniques

Tabulate pre-image uniqueness

Reply
N/A
Posts: 1

Tabulate pre-image uniqueness

Hello all,

Within Proc Tabulate, I'm trying to add a graph for my lowest-level component.  In order to do this, I've created a unique identifier for each one, then I'm trying to standardize the name to get them back to what I want for display.  However, when I standardize the name, my graphs resort to the first instance of it throughout.  Is there a way to apply the format after I've applied the images?  Or, another/better way to accomplish this?  I've included code below that produces both outputs.  What I need is a combination of the two - where the uniquename column reflects 'Me/You', but the graphs are all different. 

If you run the code, you can see in the first example that the graphs are duplicated, but the uniquename is correct.  In the second example, the graphs are correct, but I can't figure out how to correctly identify the unique name.

Thanks in advance for the assistance!


data testdata;
input category $ 1-4 person $ 6-8 metric_id $ 10-11 value 13;
datalines;
cat1 me  m1 2
cat1 you m1 4
cat2 me  m2 6
cat2 you m2 8
;
run;

data testdata;
set testdata;
rank = _n_;
uniqueName = trim(left(metric_id))||person;
run;


%macro graphs;
proc catalog c=work.gseg kill;run;quit;
goptions reset=all device=gif ftext="arial/bold" xpixels=200 ypixels=100 htext=8.75;

axis1 label=none value=none major=none minor=none style=0;
axis2 label=none value=none major=none minor=none style=0 order=(0 to 10 by 1);

%do i=1 %to 4;
data _null_;
set testdata(where=(rank=&i));
  call symput('graphName',trim(left(uniqueName)));
run;

filename outgraph "&graphname..gif";
goptions gsfname=outgraph;

proc gchart data=testdata(where=(rank=&i));
hbar person / discrete
type=sum
sumvar=value
maxis=axis1
raxis=axis2
sumlabel=none
freqlabel=none
nolegend
noframe
name="&graphname"
;
run;quit;
%end;
%mend;
%graphs;

proc format;
value $preimage
'm1me' = 'M1me.gif'
'm1you' = 'M1you.gif'
'm2me' = 'M2me.gif'
'm2you' = 'M2you.gif'
;
value $name
'm1me' = 'Me'
'm1you' = 'You'
'm2me' = 'Me'
'm2you' = 'You'
;
run;

ods html body="test.html" style=minimal;
title "Notice how graphs are the same.  The description for me/you is correct, but graphs are duplicated.";
proc tabulate data=testdata;
class category metric_id uniquename;
format uniquename $name.;
classlev uniquename / style=[preimage=$preimage.];
var value;
tables category*metric_id*uniquename
,value
;
run;

title "graphs are now correct when removing the format for me/you.  However, these need to be consistent.";
proc tabulate data=testdata;
class category metric_id uniquename;
classlev uniquename / style=[preimage=$preimage.];
var value;
tables category*metric_id*uniquename
,value
;
run;
ods html close;

Ask a Question
Discussion stats
  • 0 replies
  • 143 views
  • 0 likes
  • 1 in conversation