I have this dataset frequencies
| bucket | freq | date |
| 1 | 0.49% | 202004 |
| 1 | 0.43% | 202005 |
| 1 | 0.48% | 202102 |
| 1 | 0.46% | 202103 |
| 2 | 1.99% | 202004 |
| 2 | 2.31% | 202005 |
| 2 | 1.89% | 202006 |
| 2 | 2.70% | 202007 |
| 2 | 2.17% | 202008 |
| 2 | 1.72% | 202009 |
| 2 | 2.33% | 202010 |
| 2 | 2.27% | 202011 |
| 2 | 2.60% | 202012 |
| 2 | 3.00% | 202101 |
| 2 | 2.37% | 202102 |
| 2 | 3.06% | 202103 |
genearted by
data frequencies;
input bucket $1. freq NLPCT7.2 date $6.;
format freq NLPCT7.2;
datalines;
1 0.49% 202004
1 0.43% 202005
1 0.48% 202102
1 0.46% 202103
2 1.99% 202004
2 2.31% 202005
2 1.89% 202006
2 2.70% 202007
2 2.17% 202008
2 1.72% 202009
2 2.33% 202010
2 2.27% 202011
2 2.60% 202012
2 3.00% 202101
2 2.37% 202102
2 3.06% 202103
;
run;The time window should go from 202004 (April 2020) to 202103 (March 2021) but there are some missing frequencies for bucket 1.
When I run the sas program
proc sgplot data = frequencies;
title "frequency by date";
series x=date y=freq / GROUP=bucket;
xaxis fitpolicy=rotatethin;
run;I get the following plot
which, although I know the problem comes from the fact of missing data, I don't understand.
Is there a way to overcome this?
I would like to have both series plotted for their respective time window if possible. If not possible, I would like the missing frequency values to be assumed 0%.
Store your date as numeric/date type variable ,NOT character.
data frequencies;
input bucket : $ freq : NLPCT7.2 date : yymmn6. ;
format freq NLPCT7.2 date yymmn6.;
datalines;
1 0.49% 202004
1 0.43% 202005
1 0.48% 202102
1 0.46% 202103
2 1.99% 202004
2 2.31% 202005
2 1.89% 202006
2 2.70% 202007
2 2.17% 202008
2 1.72% 202009
2 2.33% 202010
2 2.27% 202011
2 2.60% 202012
2 3.00% 202101
2 2.37% 202102
2 3.06% 202103
;
run;
proc sgplot data = frequencies;
title "frequency by date";
series x=date y=freq / GROUP=bucket;
xaxis fitpolicy=rotatethin;
run;
I'm not getting the plot you are getting, so do us all a favor (this time, and at all times in the future). Please provide the data as SAS data step code, following these instructions: https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/ Do not provide data as Excel files or screen captures, provide data only as SAS data step code.
Thank you for the advice, as this is my first time using this platform. I edited the post.
Store your date as numeric/date type variable ,NOT character.
data frequencies;
input bucket : $ freq : NLPCT7.2 date : yymmn6. ;
format freq NLPCT7.2 date yymmn6.;
datalines;
1 0.49% 202004
1 0.43% 202005
1 0.48% 202102
1 0.46% 202103
2 1.99% 202004
2 2.31% 202005
2 1.89% 202006
2 2.70% 202007
2 2.17% 202008
2 1.72% 202009
2 2.33% 202010
2 2.27% 202011
2 2.60% 202012
2 3.00% 202101
2 2.37% 202102
2 3.06% 202103
;
run;
proc sgplot data = frequencies;
title "frequency by date";
series x=date y=freq / GROUP=bucket;
xaxis fitpolicy=rotatethin;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.