Mathematical squiggles in SAS


John D. Cook shared a picture of "pretty squiggles" on his blog, as well as a prose description of the mathematics behind it.

I'm more of a programmer than a mathematician, but I've attempted to transcribe his description into a SAS program. I used DATA step to generate the point values, and then PROC SGPLOT and the SERIES statement to plot them.

/* Create a data set with the 3 sets of data points */
data squiggle;
 do time=-100 to 100 by 0.01;
  blue = sin(time);
  /* hope I've got the golden ratio (phi) correct */
  green = 0.7 * sin( ((1+sqrt(5))/2) * time );
  red = blue+green;
ods graphics / width=2000 height=200;
/* Plot the data using a series of SERIES plots */
proc sgplot data=squiggle noautolegend;
 series x=time y=blue  
  / lineattrs=(color=blue  pattern=solid);
 series x=time y=green 
  / lineattrs=(color=green pattern=solid);
 series x=time y=red 
  / lineattrs=(color=red   pattern=solid);
 xaxis display=none ;
 yaxis display=none ;

As a variation, I included a "filled" version of the plot using the BAND statement instead of SERIES.

/* a variation that uses a BAND plot instead */
proc sgplot data=squiggle noautolegend;
 band x=time lower=0 upper=blue  
  / transparency=0.6 fillattrs=(color=blue);
 band x=time lower=0 upper=green  
  / transparency=0.6 fillattrs=(color=green);
 band x=time lower=0 upper=red  
  / transparency=0.6 fillattrs=(color=red);
 xaxis display=none;
 yaxis display=none grid;

I don't understand all of the topics that John covers in his blog, but I'm a regular reader anyway. As with Rick Wicklin's blog, I tend to feel smarter while I read it, even though I don't have the ability to explain what I've read to anyone else.


About Author

Chris Hemedinger

Director, SAS User Engagement

+Chris Hemedinger is the Director of SAS User Engagement, which includes our SAS Communities and SAS User Groups. Since 1993, Chris has worked for SAS as an author, a software developer, an R&D manager and a consultant. Inexplicably, Chris is still coasting on the limited fame he earned as an author of SAS For Dummies


  1. Hi Chris,

    Thanks for posting helpful SAS information!

    I read your posting about installing SAS on window7,

    and followed everything, thus I still see "SAS Syntax Editor control not installed" when I try to open the editor.

    Do you have any idea how to fix this?
    I found this info as well, but it doesn't have info about window7.

    Thanks for reading my question!
    Hope you can help me ;_;

    • Chris Hemedinger
      Chris Hemedinger on

      I suspect that the issue has to do with one of the Microsoft C runtime components not being installed.

      SAS has long supported Windows 7 now with later releases, so if you can, you should try a later version of SAS. But if you cannot, you may need to go back and install Microsoft Visual C 2005 runtime, and then either reinstall the Enhanced Editor component or reregister the component as per the instructions in the SAS note.

Back to Top