BookmarkSubscribeRSS Feed
SASuserlot
Barite | Level 11

I am trying to create a sem-log graph using proc template. I am able to create linear graph, but  How we can create it, I am new to how to derive geometric means, std and how they used  in semi -log graph and how to adjust the y axis values.  I also have another request ,how We  can adjust the legend highlighted in the image. I am looking to have legends one top of the other instead of horizontal. I really appreciate your help. Thanks

Present legend alignment

---o--- F   ---*--- M

Req legend alignment

---o--- F

---*--- M

Linear Graph Image

SASuserlot_0-1637192095709.png


proc means data = sashelp.class nway;
class age sex;
var weight;
output out= class_mean n=n mean= _MEAN std= sd ;
run;

data mean1;
set class_mean;

lower = _MEAN - sd;
upper = _MEAN - sd;
run;

ods path(prepend) work.templat(update);
proc template;
	define statgraph series;
	begingraph/ BORDER=False datasymbols=( circle Asterisk) ;
	   layout lattice / rowdatarange=data columndatarange=data rowgutter=10 columngutter=10;
	      layout overlay / xaxisopts=( label=('Age') tickvalueattrs=(family='Courier New' size=8 ) labelattrs=(family='Courier New' size=8 )
										linearopts=( viewmin=10 viewmax=20 tickvaluesequence=( start=0.0 end=20 increment=1)))
							yaxisopts=( label=('weight)') labelattrs=(family='Courier New' size=8 ) tickvalueattrs=(family='Courier New' size=8 )
										linearopts=( viewmin=40 viewmax=160.0 tickvaluesequence=( start=0.0 end=160.0 increment=20.0)));
	         seriesplot x=age y= _MEAN /   group=sex name='series' display=(markers) connectorder=xaxis ;
	         scatterplot x=age y= _MEAN /  yerrorupper = upper yerrorlower = lower group=trtan name='scatter';
	         discretelegend 'series' / opaque=false border=true halign=right valign=top displayclipped=true across=2 order=rowmajor location=inside titleattrs=(family='Courier New' size=8 );
	      endlayout;
	   endlayout;
	endgraph;
	end;
run;


ods graphics on/ width=9 in height=4.6 in   ;

options orientation = landscape errors = 2 missing = ' ' nofmterr ls = 175 validvarname = upcase nofmterr nobyline 
noquotelenmax ;
ods escapechar = '^';
ods results on; 
ods listing close; 
ods rtf file = "&location..\chk.rtf" 
						style = _table nogtitle nogfootnote;
	
proc sgrender data=mean1 template=series;

run;
ods rtf close;
ods listing close;

 

2 REPLIES 2
Ksharp
Super User

I am not sure if it is what you want .

 

proc template;
	define statgraph series;
	begingraph/ BORDER=False datasymbols=( circle Asterisk) ;
	   layout lattice / rowdatarange=data columndatarange=data rowgutter=10 columngutter=10;
	      layout overlay / xaxisopts=( label=('Age') tickvalueattrs=(family='Courier New' size=8 ) labelattrs=(family='Courier New' size=8 )
										linearopts=( viewmin=10 viewmax=20 tickvaluesequence=( start=0.0 end=20 increment=1)))
							yaxisopts=( label=('weight)') labelattrs=(family='Courier New' size=8 ) tickvalueattrs=(family='Courier New' size=8 )
                                      
							           type=log

										linearopts=( viewmin=40 viewmax=160.0 tickvaluesequence=( start=0.0 end=160.0 increment=20.0)));
	         seriesplot x=age y= _MEAN /   group=sex name='series' display=(markers) connectorder=xaxis ;
	         scatterplot x=age y= _MEAN /  yerrorupper = upper yerrorlower = lower group=trtan name='scatter';
	         discretelegend 'series' / opaque=false border=true halign=right valign=top displayclipped=true 

across=1  /*<------*/

order=rowmajor location=inside titleattrs=(family='Courier New' size=8 );
	      endlayout;
	   endlayout;
	endgraph;
	end;
run;

If you want "geometric means" , check

proc univariate data=have outtable=want noprint;

var have;

run;

Check geometric means in table WANT .

SASuserlot
Barite | Level 11

Hi, sorry for the confusion. I am looking to generate semi-log graph, I used type= log in the yaxisopts . how ever it still generating the  linear graph. How to generate semi -log graph for the same data?

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 782 views
  • 0 likes
  • 2 in conversation