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

Hi all,

 

I'm using GTL for the first time and am stuck on a problem. I'm practicing using the "heart" sashelp data and am trying to label the Y axis as "sex". My code is below, which does not draw a Y axis label. Having googled the problem, I don't understand why the code doesn't draw this label. For what it's worth, I use SAS 9.4 on a Windows computer.

 

Thanks!

 

data heart;
set sashelp.heart(where=(ageatstart > 56));
keep sex systolic diastolic;
run;

PROC TEMPLATE;
	DEFINE STATGRAPH jphjitter;
		DYNAMIC _title _yaxislabel;
		BEGINGRAPH /designwidth=8in designheight=6in
      				datasymbols=(circlefilled);
			ENTRYTITLE _title; *will ultimately be a dynamic;
			ENTRYFOOTNOTE HALIGN=left
						  "";
				LAYOUT LATTICE / COLUMNS = 1 ROWDATARANGE = UNION; *??? necessary;
					ROWAXES;
						ROWAXIS/DISPLAY =(TICKS TICKVALUES)
								GRIDDISPLAY = ON
								OFFSETMAX = 0.1;
					ENDROWAXES;
					LAYOUT OVERLAY / XAXISOPTS = ( display=(label tickvalues)
												   label = 'Sex'
												 )
									 YAXISOPTS = ( display=(label tickvalues)
												   label = 'SBP'
												 );
						*ENTRY TEXTATTRS = graphlabeltext 'Systolic' / valign=top;
						SCATTERPLOT X = sex Y = systolic /	JITTER = AUTO
															MARKERATTRS = (	SIZE = 8
																			SYMBOL = CIRCLEFILLED
																		  )
															;
					ENDLAYOUT;
				ENDLAYOUT;
		ENDGRAPH;
	END;
RUN;

ods listing style=htmlblue gpath='C:\Users\Benjamin\Documents\JPH Lab\Data\RQA Initial Project\Graphics\Scatter Plots'  image_dpi=&dpi;
ods graphics / reset noscale width=&w height=&h imagename='GTL_HeartBoxJitter2';
proc sgrender data=heart template=jphjitter;
dynamic _trans=0.7 _elem='graphdata3' _title = 'Systolic BP vs Sex';
run;
1 ACCEPTED SOLUTION

Accepted Solutions
djrisks
Barite | Level 11

Hi,

 

I was thinking the code could be further reduced because you are only plotting a graph with one cell, so no need for the Layout Lattice. I also put back in your output location.

 

data heart;
set sashelp.heart(where=(ageatstart > 56));
keep sex systolic diastolic;
run;

PROC TEMPLATE;
	DEFINE STATGRAPH jphjitter;
        DYNAMIC _title _yaxislabel; BEGINGRAPH /designwidth=8in designheight=6in datasymbols=(circlefilled); ENTRYTITLE _title; *will ultimately be a dynamic; ENTRYFOOTNOTE HALIGN=left ""; LAYOUT OVERLAY / XAXISOPTS = ( display=(label tickvalues) label = 'Sex' ) YAXISOPTS = ( display=(label tickvalues) label = 'SBP' ); *ENTRY TEXTATTRS = graphlabeltext 'Systolic' / valign=top; SCATTERPLOT X = sex Y = systolic / JITTER = AUTO MARKERATTRS = ( SIZE = 8 SYMBOL = CIRCLEFILLED ); ENDLAYOUT; ENDGRAPH; END; RUN; ods listing style=htmlblue gpath='C:\Users\Benjamin\Documents\JPH Lab\Data\RQA Initial Project\Graphics\Scatter Plots' image_dpi=&dpi; ods graphics / reset noscale width=&w height=&h imagename='GTL_HeartBoxJitter2'; proc sgrender data=heart template=jphjitter; dynamic _trans=0.7 _elem='graphdata3' _title = 'Systolic BP vs Sex'; run;

View solution in original post

5 REPLIES 5
djrisks
Barite | Level 11

Try this code please.

 

It's because you were using the rowaxes column.

 

data heart;
set sashelp.heart(where=(ageatstart > 56));
keep sex systolic diastolic;
run;

PROC TEMPLATE;
	DEFINE STATGRAPH jphjitter;
		DYNAMIC _title _yaxislabel;
		BEGINGRAPH /designwidth=8in designheight=6in
      				datasymbols=(circlefilled);
			ENTRYTITLE _title; *will ultimately be a dynamic;
			ENTRYFOOTNOTE HALIGN=left
						  "";
				LAYOUT LATTICE / COLUMNS = 1; *??? necessary;
					LAYOUT OVERLAY / XAXISOPTS = ( display=(label tickvalues)
												   label = 'Sex'
												 )
									 YAXISOPTS = ( display=(label tickvalues)
												   label = 'SBP'
												 );
						*ENTRY TEXTATTRS = graphlabeltext 'Systolic' / valign=top;
						SCATTERPLOT X = sex Y = systolic /	JITTER = AUTO
															MARKERATTRS = (	SIZE = 8
																			SYMBOL = CIRCLEFILLED
																		  )
															;
					ENDLAYOUT;
				ENDLAYOUT;
		ENDGRAPH;
	END;
RUN;

ods listing style=htmlblue gpath='C:\Users\yex7977\Desktop\Helpful plots'  image_dpi=&dpi;
ods graphics / reset noscale width=&w height=&h imagename='GTL_HeartBoxJitter2';
proc sgrender data=heart template=jphjitter;
dynamic _trans=0.7 _elem='graphdata3' _title = 'Systolic BP vs Sex';
run;
djrisks
Barite | Level 11

Hi,

 

I was thinking the code could be further reduced because you are only plotting a graph with one cell, so no need for the Layout Lattice. I also put back in your output location.

 

data heart;
set sashelp.heart(where=(ageatstart > 56));
keep sex systolic diastolic;
run;

PROC TEMPLATE;
	DEFINE STATGRAPH jphjitter;
        DYNAMIC _title _yaxislabel; BEGINGRAPH /designwidth=8in designheight=6in datasymbols=(circlefilled); ENTRYTITLE _title; *will ultimately be a dynamic; ENTRYFOOTNOTE HALIGN=left ""; LAYOUT OVERLAY / XAXISOPTS = ( display=(label tickvalues) label = 'Sex' ) YAXISOPTS = ( display=(label tickvalues) label = 'SBP' ); *ENTRY TEXTATTRS = graphlabeltext 'Systolic' / valign=top; SCATTERPLOT X = sex Y = systolic / JITTER = AUTO MARKERATTRS = ( SIZE = 8 SYMBOL = CIRCLEFILLED ); ENDLAYOUT; ENDGRAPH; END; RUN; ods listing style=htmlblue gpath='C:\Users\Benjamin\Documents\JPH Lab\Data\RQA Initial Project\Graphics\Scatter Plots' image_dpi=&dpi; ods graphics / reset noscale width=&w height=&h imagename='GTL_HeartBoxJitter2'; proc sgrender data=heart template=jphjitter; dynamic _trans=0.7 _elem='graphdata3' _title = 'Systolic BP vs Sex'; run;
Rick_SAS
SAS Super FREQ

You say you are using SAS 9.4.   Therefore you can use the JITTER option on the SCATTER statement in PROC SGPLOT. No need to mess with the GTL. For an example, see

http://blogs.sas.com/content/graphicallyspeaking/2013/07/10/make-better-graphs-with-sas-9-4/

 

 

benbuck
Obsidian | Level 7
Thanks for the help! I've meaning to learn to use GTL for a while and these are my first baby steps into it.
djrisks
Barite | Level 11
You're welcome. I understand. There's a lot of helpful information out there such as the graphically speaking SAS blog and the PharmaSUG and SAS Global Forum Papers. This is a supportive community that will help you to learn more about GTL too. ☺

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
  • 5 replies
  • 1607 views
  • 2 likes
  • 3 in conversation