Graphics Programming

Data visualization using SAS programming, including ODS Graphics and SAS/GRAPH. Charts, plots, maps, and more!
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sks521
Quartz | Level 8

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;
1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

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 ; 
Thanks,
Jag

View solution in original post

5 REPLIES 5
Jagadishkatam
Amethyst | Level 16

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 ; 

 

 

image.png

Thanks,
Jag
sks521
Quartz | Level 8

Hi,

 

I want something like the following but can't label quarters on X-axis as for example Jan-Mar12 instead of quarter 1;SGPlot.png

Jagadishkatam
Amethyst | Level 16

Please try the below code

 

PROC SGPLOT  DATA = control1_plot; 
  series x=quarter y=control;
    series x=quarter y=intervention;
RUN ; 

 

 

image.png

Thanks,
Jag
sks521
Quartz | Level 8

I had but it's giving me something like this;SGPlot2.png

Jagadishkatam
Amethyst | Level 16

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 ; 
Thanks,
Jag

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1043 views
  • 1 like
  • 2 in conversation