Hi folks,
Could you please help defining min value for x axis be 1 and max be 12 on this plot work?
Seems easy but i couldn't find any solution yet except using min=1 and max=12 with no success.
data have;
input N_MONTH_ENROLLED WGT_DX MEAN_DAYS;
cards;
1 1 17.2
1 2 5.8
1 3 14.6
1 4 126.0
1 6 6.9
1 99 19.2
2 1 21.4
2 2 39.5
2 3 15.9
2 4 76.6
2 6 1.4
2 99 15.7
3 1 28.1
3 2 3.6
3 3 12.7
3 4 0.0
3 5 0.0
3 6 5.8
3 99 16.8
4 1 19.6
4 2 55.3
4 3 10.6
4 4 28.2
4 5 0.0
4 6 6.9
4 99 19.7
5 1 15.4
5 2 8.4
5 3 7.1
5 4 11.7
5 5 2.3
5 6 2.6
5 99 18.1
6 1 18.0
6 2 41.5
6 3 11.0
6 4 27.4
6 5 0.3
6 6 0.7
6 99 16.5
7 1 14.0
7 2 0.0
7 3 7.9
7 4 0.1
7 5 0.0
7 6 0.9
7 99 9.6
8 1 9.1
8 2 0.0
8 3 4.6
8 4 13.2
8 5 3.5
8 6 3.2
8 99 11.0
9 1 9.9
9 2 1.4
9 3 3.9
9 4 4.2
9 5 0.0
9 6 0.8
9 99 6.0
10 1 7.3
10 2 5.4
10 3 6.0
10 4 1.1
10 5 0.0
10 6 0.8
10 99 7.2
11 1 6.8
11 2 0.1
11 3 2.8
11 4 3.4
11 5 0.3
11 6 1.8
11 99 5.4
12 1 1.3
12 2 0.2
12 3 0.4
12 4 0.3
12 5 0.0
12 6 0.1
12 99 1.4
;
proc print; run;
ods graphics / height=300px width=1200px;
TITLE "hello";
proc sgpanel data=have;
panelby wgt_dx/onepanel novarname ROWS=1 ;
series x=N_MONTH_ENROLLED y=MEAN_DAYS/ markerattrs=(size=3px);
colaxis label='hi' MIN=1 fitpolicy=thin valuesformat=best4.0;
rowaxis label='hirow' grid;
TITLE "MEAN DIFFERENCE IN DAYS BY NUMBER OF MONTH WITH MEDICAID INSURANCE STRATIFIED BY DIAGNOSIS GROUPS";
format WGT_DX WGT_DX.;
run;
@Cruise wrote:
I was hoping to create a high-resolution image. tweaking with that would help show x-axis value without a cut 1 thru 12? Has sizing of the plot an effect on the x-axis values?
Any of the graphs will be limited as to what they can display given a physical limitation of the graphic display area. Note that the first graph because the width is kind of narrow that the xaxis labels get thinned but the other doesn't (at least on my display).
ods graphics/ height=2in width=2in; proc sgplot data=sashelp.class; scatter x=height y=weight; xaxis values= (0 to 80 by 5); run; ods graphics/ height=2in width=4in; proc sgplot data=sashelp.class; scatter x=height y=weight; xaxis values= (0 to 80 by 5); run;
So a wider display may alleviate the tick mark fit issue.
Depending on exactly what you mean by "high resolution" that may be more a function of the specific ODS destination.
For example the ODS HTML destination has an option IMAGE_DPI that specifies the "dots per inch" or resolution generate when the ODS GRAPHICS option NOIMAGEMAP, the default, is set.
ODS PDF uses the DPI= option to control resolution.
ODS RTF also uses IMAGE_DPI but the default is 200 instead of the 96 that HTML uses.
Using large values of dpi options may increase memory requirements.
Vector graphic image files would behave differently in most respects for online viewing.
Have you tried putting an Xaxis or Yaxis statement in the proc?
proc sgpanel data=have;
panelby wgt_dx/onepanel novarname ROWS=1 ;
series x=N_MONTH_ENROLLED y=MEAN_DAYS/ markerattrs=(size=3px);
colaxis label='hi' MIN=1 fitpolicy=thin valuesformat=best4.0;
rowaxis label='hirow' grid;
xaxis min=1 max=12; /* Here */
format WGT_DX WGT_DX.;
run;
For instance
Oh, yes, sorry, doesn't work with sgpanel. Looking at a previous post:
You seem to have been over this before?
If you want full control over the each part of it, I would suggest moving to GTL. Create a template with columns/rows and set each graph distinctly. So with layout gridded you can set x/yaxis attributes individually for each graph, or default them.
i tried this with no success, it works but cuts 12 from display and my range appears to be 1 thru 11 on the plot.
colaxis label='N of months with Medicaid coverage' MIN=1 MAX=12 fitpolicy=thin valuesformat=best2.0 values=(1 to 12);
I will take a look at the GTL? i never tried before.
Add tmplout= to your current sgpanel statement and direct it to a text file, that will give you the basis (all splots create GTL behind the scenes):
proc sgpanel data=have tmplout="c:/test.txt";
From that you can then manipulate it.
Add an option into colaxis.
colaxis label='hi' integer .....................
colaxis label='hi' values=(1 to 12 by 1);
Hi Ksharp, the problem remains even after specifying that in colaxis. Mt plot shows as I have 11 points but actually I have 12 months for each month from jan thru dec.
ods graphics / height=300px width=1250px;
TITLE "hello";
proc sgpanel data=have;
panelby wgt_dx/onepanel novarname ROWS=1 ;
series x=N_MONTH_ENROLLED y=MEAN_DAYS / markerattrs=(size=3px);
colaxis label='N of months with Medicaid coverage' fitpolicy=thin valuesformat=best2.0 values=(1 to 12 by 1);
rowaxis label='Mean difference in days' grid;
TITLE "title";
run;
Where did the decision to use a width of 1250 pixels come from?
Perhaps just making the graphic area a little wider would do.
Or set the font size smaller for the values using the labelattrs option such as labelattrs=(size=6pt)
I was hoping to create a high-resolution image. tweaking with that would help show x-axis value without a cut 1 thru 12? Has sizing of the plot an effect on the x-axis values?
@Cruise wrote:
I was hoping to create a high-resolution image. tweaking with that would help show x-axis value without a cut 1 thru 12? Has sizing of the plot an effect on the x-axis values?
Any of the graphs will be limited as to what they can display given a physical limitation of the graphic display area. Note that the first graph because the width is kind of narrow that the xaxis labels get thinned but the other doesn't (at least on my display).
ods graphics/ height=2in width=2in; proc sgplot data=sashelp.class; scatter x=height y=weight; xaxis values= (0 to 80 by 5); run; ods graphics/ height=2in width=4in; proc sgplot data=sashelp.class; scatter x=height y=weight; xaxis values= (0 to 80 by 5); run;
So a wider display may alleviate the tick mark fit issue.
Depending on exactly what you mean by "high resolution" that may be more a function of the specific ODS destination.
For example the ODS HTML destination has an option IMAGE_DPI that specifies the "dots per inch" or resolution generate when the ODS GRAPHICS option NOIMAGEMAP, the default, is set.
ODS PDF uses the DPI= option to control resolution.
ODS RTF also uses IMAGE_DPI but the default is 200 instead of the 96 that HTML uses.
Using large values of dpi options may increase memory requirements.
Vector graphic image files would behave differently in most respects for online viewing.
Wonderful! Worked out.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.