12-09-2016 01:27 PM
Here is my data:
Is there a way to do either of the following:
1) a simple set of histograms, one for each grouped_var, that adds up the number of observations for that group each month? (I would rather not type out each group_var, as there are more than just a,b, and c.)
2) a multiple series line chart that has a separate series for each grouped_var that shows the number of occurences of for each month?
I searched but couldn't find the answer, so thank you so much in advance!
12-09-2016 01:52 PM - edited 12-09-2016 01:57 PM
What you are looking for is called a "comparative histogram," and searching on that term will lead you to many articles, including this summary article "Comparative histograms: Panel and overlay histograms in SAS." From your description, it sounds like you want to use the panel approach:
proc sgpanel data=sashelp.iris; panelby group-var; histogram datetime; run;
You might want to add a COLAXIS statement and specify the INTERVAL= option to get axis ticks that are convenient for your data.
I'm not sure what you mean by a "multiple time series chart" for this data. Look at the VLINE statement and the STAT=SUM option. However, I think you would need to bin the data to the month level, probably by using a format. Thus try starting with the following:
proc sgpanel data=A; format datetime DTMONYY5.; panelby groupvar; vbar datetime / stat=sum; /* I prefer VBAR */ vline datetime / stat=sum markers break; run;
12-09-2016 03:43 PM
Pet peeve: DATES and DATETIMES are different, especially in SAS. So do you want dates or datetimes for your histogram?
What would be the Y variable for a series chart? You show a group variable and an x axis variable but a series is going to want something to show as a Y.
12-12-2016 11:22 PM