BookmarkSubscribeRSS Feed
t75wez1
Pyrite | Level 9

Hi all,

I found one good graph described customer life value. I wonder if SAS can produce the similar shape of curves.

Sorry I don't have any data.

Any suggestions?

 

Thanks,

Ethan

 

 

 

 

 

4 REPLIES 4
DanH_sas
SAS Super FREQ

Here are some thoughts for you using SGPLOT overlays:

 

1. The "Profit" area can be done using using a BAND plot with a constant lower value (lower=0, for instance)

2. The line curves can be done using SERIES plots. I would use the SMOOTHCONNECT option to keep them smooth

3. The arrows can be drawn using a HIGHLOW plot, using TYPE=BAR and HIGHCAP=FILLEDARROW

 

Hope this helps!

Dan

t75wez1
Pyrite | Level 9

Dan,

Thanks a lot. Very helpful suggestion.

I started developing the attached code that seems accomplish the 1) you mentioned.

But I don't know how to put all together.

Could you offer further helps for 2) and 3)? 

 

Regards,

 

Ethan

 

  

DanH_sas
SAS Super FREQ

Using your code, I added some extra data so that you can see how the other two plots can be used.

 

%let THRESHOLD = 0;
data wave;
t=0;
do x=0 to 6 by .05;
y=sin(0.5*x);
y2=sin(0.5*x) + 0.5;
if t = 20 then do;
   upper = y2;
   lower = y;
   t = 0;
end;
else do;
   upper=.;
   lower=.;
   t=t+1;
end;
positive = y;
negative = &THRESHOLD;
;
output;
end;
run;

ods path(prepend) work.templat(update);
proc template;
   define style mystyle;
   parent=styles.sasweb;
      class graphwalls /
            frameborder=off;
      class graphbackground /
            color=white;
   end;
run;

ods listing close;
ods html style=mystyle path='.' file='newgraph.html';
ods graphics / reset=all border=off width=600px height=400px imagename="cdh2";
proc print data=wave; run;
proc sgplot data=wave noautolegend;

YAXIS  DISPLAY=NONE  LABEL = " "  ;
XAXIS   DISPLAY=NONE LABEL = " "  ;
band x=x lower=&THRESHOLD
upper=positive / transparency=0.5;
band x=x lower=negative
upper=&THRESHOLD /
transparency=0.5;
series x=x y=y2 / smoothconnect lineattrs=(color=blue thickness=3);
highlow x=x high=upper low=lower / type=bar highcap=filledarrow intervalbarwidth=30px;
title " ";
footnote "";
run;

ods html close;
ods listing;

Hope this helps!

Dan

t75wez1
Pyrite | Level 9

Thank to Dan for the great progress made so far. Now I understander how to put the 3 things together.

But if I want to make the graph more look like the attached graph from my initial post, my challenge is to figure out on how to create the data to form the curves in order to achieve the desired results since the curves are not symmetric.

 

I'm really apprecitive of any helps.

 

Ethan

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1084 views
  • 0 likes
  • 2 in conversation