I just started using SAS at work and have been learning on my own for a few weeks before we get sent off to formal training. The question that I have is how can I group by a formatted date The field that I have is a date time field, and what I want to do is group that date by YYYYMMs format. Once my date is in the proper format, I'm unable to group by that format; SAS seems to revert back to the field's original format despite showing it in the format that I desire.
The only way I have gotten around this is to turn my date field into YYYMMs as a character field, but the obviously I lose some date functionality. Any suggestions?
Some SAS procedures use the formats, others ignore them. So the answer is: It depends.
For instance, PROC MEANS uses formats for the CLASS statement but not for the VAR statement. FREQ uses them throughout. REG ignores them for continuous variables. The DATA step generally ignores formats in expressions, but there are functions to allow you to get the formatted value [PUT(varname, format.), for instance].
You probably need to read the chapters on Dates and formats in the Base manual and scan the procedure manuals for 'format' in the PROC chapters that are of interest. For us to provide more specific suggestions, we'll need a more specific question.