Graphics Programming

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

Im trying to present the Y axis on log base 10 . This is a multipage plot and Y axis keep changing. As per the Code below, I get the following graph. The Y axis appears as 1E0, 1E1 etc.  My project needs this to be presented as 1, 10^1, 10^2 etc

Manj_0-1730296526688.png

 


%macro grph(byval=,ylbl=,insettxt=);

ods escapechar='^';
ods graphics on / reset=all height=8cm width=22.0cm border=off outputfmt=png ;

/*height=8cm width=22.0cm*/


proc sgplot data=in(where=(paramcd=&byval)) dattrmap=myattr;
series x=visnx y=median /group=studyid lineattrs=(pattern=1) attrid=studyid name="v1";
scatter x=visnx y=median/group=studyid yerrorlower=p25 yerrorupper=p75 markerattrs=(symbol=CircleFilled) attrid=studyid name="v2" ;

xaxis label='Post-Dose Visit' values=(1 4 7 15 25 35 45 65 85 105 125 165 ) valuesdisplay=('D1' 'D2' 'D3' 'Wk1/D7' 'Wk2/D14' 'Wk3' 'Wk4/Mnth1' 'Wk6' 'Wk8' 'Wk10' 'Wk12' 'Wk52/EOS' ) fitpolicy=rotate valuesrotate=diagonal valueattrs=(size=8);
yaxis min=1 label=&ylbl valueattrs=(size=8) TYPE=LOG logvtype=EXPANDED LOGBASE=10;
refline lloq / axis=y lineattrs=(pattern=2 color=grey);
inset &insettxt /position=top;
keylegend "v1" / title="" position=topright location =inside across=1 valueattrs=(size=8) noborder;
run;
ods graphics off;
%mend;
%grph(byval="SSSS",ylbl='vg/g',insettxt='Vital shedding');

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @Manj,

 

You can define a format which displays 10 as "10^1", 100 as "10^2" and so on ...

data fmt;
retain fmtname 'expfmt';
length label $6;
do e=0 to 15;
  start=10**e;
  if e=0 then label='1';
  else label=cats('10^',e);
  output;
end;
run;

proc format cntlin=fmt;
run;

... and then add the VALUESFORMAT= option to your YAXIS statement, referring to that format:

valuesformat=expfmt.

 

An alternative format definition could use superscripts for the exponents (10¹, 10², ...):

proc format;
value supexpfmt
1='1'
1e1="10(*ESC*){unicode '00B9'x}"
1e2="10(*ESC*){unicode '00B2'x}"
1e3="10(*ESC*){unicode '00B3'x}"
1e4="10(*ESC*){unicode '2074'x}"
1e5="10(*ESC*){unicode '2075'x}"
1e6="10(*ESC*){unicode '2076'x}"
1e7="10(*ESC*){unicode '2077'x}"
1e8="10(*ESC*){unicode '2078'x}"
1e9="10(*ESC*){unicode '2079'x}"
1e10="10(*ESC*){unicode '00B9'x}(*ESC*){unicode '2070'x}"
1e11="10(*ESC*){unicode '00B9'x}(*ESC*){unicode '00B9'x}"
1e12="10(*ESC*){unicode '00B9'x}(*ESC*){unicode '00B2'x}"
1e13="10(*ESC*){unicode '00B9'x}(*ESC*){unicode '00B3'x}"
1e14="10(*ESC*){unicode '00B9'x}(*ESC*){unicode '2074'x}"
1e15="10(*ESC*){unicode '00B9'x}(*ESC*){unicode '2075'x}"
;
run;

However, this would require a suitable font:

valueattrs=(size=8 family='Arial Unicode MS') valuesformat=supexpfmt.

View solution in original post

1 REPLY 1
FreelanceReinh
Jade | Level 19

Hello @Manj,

 

You can define a format which displays 10 as "10^1", 100 as "10^2" and so on ...

data fmt;
retain fmtname 'expfmt';
length label $6;
do e=0 to 15;
  start=10**e;
  if e=0 then label='1';
  else label=cats('10^',e);
  output;
end;
run;

proc format cntlin=fmt;
run;

... and then add the VALUESFORMAT= option to your YAXIS statement, referring to that format:

valuesformat=expfmt.

 

An alternative format definition could use superscripts for the exponents (10¹, 10², ...):

proc format;
value supexpfmt
1='1'
1e1="10(*ESC*){unicode '00B9'x}"
1e2="10(*ESC*){unicode '00B2'x}"
1e3="10(*ESC*){unicode '00B3'x}"
1e4="10(*ESC*){unicode '2074'x}"
1e5="10(*ESC*){unicode '2075'x}"
1e6="10(*ESC*){unicode '2076'x}"
1e7="10(*ESC*){unicode '2077'x}"
1e8="10(*ESC*){unicode '2078'x}"
1e9="10(*ESC*){unicode '2079'x}"
1e10="10(*ESC*){unicode '00B9'x}(*ESC*){unicode '2070'x}"
1e11="10(*ESC*){unicode '00B9'x}(*ESC*){unicode '00B9'x}"
1e12="10(*ESC*){unicode '00B9'x}(*ESC*){unicode '00B2'x}"
1e13="10(*ESC*){unicode '00B9'x}(*ESC*){unicode '00B3'x}"
1e14="10(*ESC*){unicode '00B9'x}(*ESC*){unicode '2074'x}"
1e15="10(*ESC*){unicode '00B9'x}(*ESC*){unicode '2075'x}"
;
run;

However, this would require a suitable font:

valueattrs=(size=8 family='Arial Unicode MS') valuesformat=supexpfmt.

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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
  • 1 reply
  • 822 views
  • 3 likes
  • 2 in conversation