Hi folks,
I am trying to plot the following data where 'quarter' should be X-axis and number of visits per group (control and intervention) on Y-axis but when I plot it using proc SGplot, it doesn't pick all quarters points, it only picks four quarters on x-axis and draws strange lines.
How do I fix that please?
Ta
data control1_plot; input Quarter $ Control intervention; datalines; Jan-Mar12 274 109 Apr-Jun12 769 148 Jul-Sep12 1242 276 Oct-Dec12 1015 226 Jan-Mar13 755 176 Apr-Jun13 800 134 Jul-Sep13 1078 270 Oct-Dec13 1283 207 Jan-Mar14 862 160 Apr-Jun14 1004 193 Jul-Sep14 1215 181 Oct-Dec14 1767 251 Jan-Mar15 1090 145 Apr-Jun15 1120 149 Jul-Sep15 1402 239 Oct-Dec15 1728 239 Jan-Mar16 1412 124 Apr-Jun16 1402 147 Jul-Sep16 1632 208 Oct-Dec16 1783 215 Jan-Mar17 1238 157 ; run;
Please try with the entire code below
data control1_plot;
input Quarter :$10. Control intervention;
datalines;
Jan-Mar12 274 109
Apr-Jun12 769 148
Jul-Sep12 1242 276
Oct-Dec12 1015 226
Jan-Mar13 755 176
Apr-Jun13 800 134
Jul-Sep13 1078 270
Oct-Dec13 1283 207
Jan-Mar14 862 160
Apr-Jun14 1004 193
Jul-Sep14 1215 181
Oct-Dec14 1767 251
Jan-Mar15 1090 145
Apr-Jun15 1120 149
Jul-Sep15 1402 239
Oct-Dec15 1728 239
Jan-Mar16 1412 124
Apr-Jun16 1402 147
Jul-Sep16 1632 208
Oct-Dec16 1783 215
Jan-Mar17 1238 157
;
run;
PROC SGPLOT DATA = control1_plot;
series x=quarter y=control;
series x=quarter y=intervention;
RUN ;
Is this what you are expecting, but the y axis can be only one per graph either control or intervention
here i used control, Please let me know how you need the graph if this is not the expected one
PROC SGPLOT DATA = control1_plot;
VBAR quarter / REsponse = control;
RUN ;
Hi,
I want something like the following but can't label quarters on X-axis as for example Jan-Mar12 instead of quarter 1;
Please try the below code
PROC SGPLOT DATA = control1_plot;
series x=quarter y=control;
series x=quarter y=intervention;
RUN ;
I had but it's giving me something like this;
Please try with the entire code below
data control1_plot;
input Quarter :$10. Control intervention;
datalines;
Jan-Mar12 274 109
Apr-Jun12 769 148
Jul-Sep12 1242 276
Oct-Dec12 1015 226
Jan-Mar13 755 176
Apr-Jun13 800 134
Jul-Sep13 1078 270
Oct-Dec13 1283 207
Jan-Mar14 862 160
Apr-Jun14 1004 193
Jul-Sep14 1215 181
Oct-Dec14 1767 251
Jan-Mar15 1090 145
Apr-Jun15 1120 149
Jul-Sep15 1402 239
Oct-Dec15 1728 239
Jan-Mar16 1412 124
Apr-Jun16 1402 147
Jul-Sep16 1632 208
Oct-Dec16 1783 215
Jan-Mar17 1238 157
;
run;
PROC SGPLOT DATA = control1_plot;
series x=quarter y=control;
series x=quarter y=intervention;
RUN ;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.