And if you need only months, not complete dates (eg because you want to work with months across years), then store the months as numbers 1-12 and apply a custom format to show month names.
You could use SQL, which is more flexible to order data the way you want it.
Just use an available informat or create one that will create the sequence needed, for example:
proc format; invalue MNTH (upcase) 'JAN'=1 'FEB'=2 'MAR'=3 'APR'=4 'MAY'=5 'JUN'=6 'JUL'=7 'AUG'=8 'SEP'=9 'OCT'=10 'NOV'=11 'DEC'=12 other=-1; run; * create custom informat; proc sql; create table WANT as select * from HAVE order by input(VAR,MNTH.); * order using the informat; quit;
ORDER BY will accept functions and you can combine more than one variable.
Hope it helps.
Daniel Santos @ www.cgd.pt
Given the fixed and relatively limited number of values of the sort variable, this is a case where your knowledge of the data might avoid the need for proc sort, possibly saving lots of intermediate disk input/output activity:
data want; set have (where=(month='JAN')) have (where=(month='FEB')) have (where=(month='MAR')) have (where=(month='APR')) have (where=(month='MAY')) have (where=(month='JUN')) have (where=(month='JUL')) have (where=(month='AUG')) have (where=(month='SEP')) have (where=(month='OCT')) have (where=(month='NOV')) have (where=(month='DEC')) open=defer; run;
The "open=defer" option tells SAS not to allocate memory to simultaneously creating input buffers for all 12 SET datasets. Just use the same buffer 12 times, in sequence. You can get away with this option if (1) all the buffers would accomodate the same variables and (2) you do not use a BY statement (which would require SAS to determine record order by comparing inputs from all sources).
Of course, the downside of this approach is that, even though no utility/intermediate files are created (i.e. no excess disk output), it does read dataset HAVE 12 times. There is a tradeoff between number of sort levels and sort-utility file needs.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.