Description Below adaptable SAS code for generation of recency, frequency and monetary variables. Algorithm may be applied in a lot of contexts in which records contain dates ('day of entry', 'day of exit', 'day of visit') id number and maybe even revenue or cost. Citation Please cite this code as: Laier, G.H. (2016) Recency, Frequency and Monetary SAS programming script [computer software]. Denmark. Link: http://hellmund.blogspot.dk/2016/02/recency-frequency-monetary-rtf-variable.html Thanks! Gunnar Hellmund Laier, PhD, MSc Explanation In this context we form variable for analyses of Danish National Register data and form variables containing information on contacts, hospitalizations and days in hospital 14, 30, 91 and 180 days before a hospitalization or contact. Key variables: cpr (security number), pattype (patient type, in- or outpatient), inddto (day of entry), uddto (day of exit), ambdto (day of visit). Data step program data calc.