BookmarkSubscribeRSS Feed
LauraRK
Quartz | Level 8

Well not as good as polar rose valentines inspired by Rick Wicklin https://communities.sas.com/t5/Graphics-Programming/Challenge-for-SAS-Nerds-Build-a-SAS-Valentine/m-...  

I was short on time given given the pandemic, but if you want something cute:

 mix_valentine.png

outlier_valentine.png

skewed_valentine.png

/* Laura Kapitula's geeky valentines 2021";

/* simulate */
ods graphics/ height=3in;
title height=2 color=black "Valentine, let's mix our distributions.";
data sim;

do i= 1 to 10000;
  p=rand('bernoulli',.5); 
  if p=1 then do;
     person = 'you';
       x=rand('chisq',10)+4;
  end;
  else if p=0 then do;
       person='me ';
	  x= rand('normal',3,4);
  end; 
  output;
end;
run;

proc sgplot data=sim;
  histogram x/ group=person  transparency=.5  ;
    keylegend / location=inside down=3 noborder position=topright fillheight=20 title=" ";
  density x / group=person type=kernel ;
  xaxis display=none;

run;


data sim2;
  do i= 1 to 100;
    x=rand('normal', 100,20);
    if 47<x<155 then output;
  end;
  x=170; label='you'; output;
run;

ods graphics / width=6in height=1.5in;
title height=2 color=black "Valentine, you are a positive outlier.";
proc sgplot data=sim2 noborder;
  hbox x / datalabel=label  fillattrs=(color=pink) lineattrs=(color=red thickness=2) whiskerattrs=(color=red thickness=2) 
outlierattrs=(size=30 symbol=heartfilled color=red  ) medianattrs=(color=red thickness=2) meanattrs=(color=red)
datalabelattrs=(weight=bold color=crimson size=12)  boxwidth=1   ; 
  xaxis display=none;
run;

ods graphics/ height=3in;
title height=2 color=black "Valentine, I love that you are positively skewed.";
data sim3;

do i= 1 to 10000;
      person = 'you';
       x=rand('gamma',2,2);
    output;
end;
run;

proc sgplot data=sim3 noautolegend;
  histogram x/  fillattrs=(color=pink) nooutline   ;
  density x / type=kernel lineattrs=(color=red thickness=2) ;
  xaxis display=none;
run;
2 REPLIES 2
djrisks
Barite | Level 11

Awesome graph Laura! This has really inspired me! 🙂 I really like the let's mix our distribution graph! 

LauraRK
Quartz | Level 8
that is my favorite of these as well. My real favorite is the animated polar roses, but I like these for their simplicity. Lot's of fun with SGPLOT .

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
  • 2 replies
  • 1356 views
  • 7 likes
  • 2 in conversation