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!
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;
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.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.