A SAS macro for modelling periodic data using cosinor analysis
Related Experiment Video
Updated: Oct 25, 2025

A Method of Trigonometric Modelling of Seasonal Variation Demonstrated with Multiple Sclerosis Relapse Data
Published on: December 9, 2015
Margaret M Doyle1, Terrence E Murphy1, Margaret A Pisani2
1Section of Geriatrics, Department of Internal Medicine, Yale School of Medicine, 300 George Street Suite 775, New Haven, CT, United States.
Background And Objective:
Cosinor analysis, developed by Franz Hallberg and colleagues in the 1960s, allows for the fitting of a cosine curve to data of a known period. Cosinor analysis is frequently used in the analysis of biological rhythm data. While software exists to perform these analyses, we are not aware of any published SAS procedures or macros which would facilitate them.
Methods:
To meet this gap, we herein describe SAS macros which perform cosinor analyses that assume either normally or gamma distributed outcomes and fixed period. The macros can 1) produce datasets with cosinor parameters including acrophase, mesor, amplitude, nadir and test for rhythmicity 2) output datasets with fitted and observed values from the model, and 3) plot the resulting curve and underlying data.
Results:
We demonstrate the use of these macros with data from our research on circadian rhythms of heart rate and sleep in critically ill patients.
Conclusions:
Cosinor analysis provides a parsimonious and intuitive set of estimates to summarize periodic data. We are hopeful that the publication of our macro will allow a wider spectrum of users to avail themselves of this technique.
Related Concept Videos
Graphical and Analytic Representation of Sinusoids
The first step is measuring the peak-to-peak value, which is twice the amplitude of the sinusoid. This provides information about the maximum voltage swing of the waveform.
Secondly, the period and angular frequency are determined. The period is the time taken for one complete cycle of the waveform, while...
Exponential and Sinusoidal Signals
Trigonometric Fourier series
The trigonometric Fourier series specifically expresses a periodic function with a defined period T using sine...
Exponential Fourier series
Euler's identity...
Trigonometric Equations
Statistical Analysis System (SAS)
Applications: SAS finds applications in numerous fields, including healthcare for clinical trial analysis, finance for risk assessment, marketing for customer data analysis, and...

