I have data set with SAS date variable spanning several years.
I want to create a variable that contains the year and the quarter (e.g 2010Q2), which can then be used to sort by.
Hi:
Read about the various YYQ formats. For example, a SAS date value for 03/15/2006 could be used to create a character variable called QTRVAL with this code:
[pre]
qtrval = put(date,yyq6.);
[/pre]
With a multiple-variable BY statement, the order of observations that have date values throughout a given quarter, may get sorted differently if only considering the "formatted" value sort-sequence, presuming the BY statement has additional variables to the right of the date variable itself.