BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Cruise
Ammonite | Level 13

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

Accepted Solutions
ballardw
Super User

@Cruise wrote:

@ballardw 

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.

View solution in original post

12 REPLIES 12
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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 

Cruise
Ammonite | Level 13
Hi. This gave me an error:
ERROR 180-322: Statement is not valid or it is used out of proper order.
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Oh, yes, sorry, doesn't work with sgpanel.  Looking at a previous post:

https://communities.sas.com/t5/Graphics-Programming/proc-sgpanel-y-axis-with-multiple-scales/td-p/42...

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.

http://support.sas.com/documentation/cdl/en/grstatgraph/65377/HTML/default/viewer.htm#p1o5obcsv23eb6...

Cruise
Ammonite | Level 13

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. 

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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. 

Ksharp
Super User

Add an option into colaxis.

colaxis label='hi'  integer  .....................
Ksharp
Super User
colaxis label='hi' values=(1 to 12 by 1);
Cruise
Ammonite | Level 13

@Ksharp 

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;

ksharp.png

ballardw
Super User

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)

 

Cruise
Ammonite | Level 13

@ballardw 

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?

ballardw
Super User

@Cruise wrote:

@ballardw 

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.

Cruise
Ammonite | Level 13

Wonderful! Worked out. 

 

SGPanel13.png

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 12 replies
  • 10622 views
  • 3 likes
  • 4 in conversation