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

How can I set the number of decimal places for a particular axis when creating a line graph using PROC SGPLOT?

I'd like to set it to 1 decimal place for the Y-axix (This syntax uses output means from PROC UNIVARIATE).

I consulted this post, but the "valuesformat=" option isn't working for me either. 

 

Current graph (4 decimal places):

Screen Shot 2021-11-19 at 4.25.34 PM.png

 

PROC SGPLOT data=data_02_output;
	series x=time y=mean_efflux / lineattrs=(thickness=3px) group=group
		markers markerattrs=(size=10pt) DATALABEL DATALABELATTRS=(Color=grey Family="Arial" Size=12
        Style=Italic Weight=Bold);

	yaxis
	 values=(5 to 15 BY 5) valuesformat=3.1 label='Efflux (% efflux / 4 hours)'
	 labelattrs=(size=12pt weight=bold color=gray33)
	 valueattrs=(size=12pt weight=bold color=gray33)
	 offsetmin=0 offsetmax=0 grid minor minorcount=1
	 ;
	 
	xaxis
	 values=(1 to 3 BY 1) label='Visit Number'
	 labelattrs=(size=12pt weight=bold color=gray33)
	 valueattrs=(size=12pt weight=bold color=gray33)
	 offsetmin=0 offsetmax=0 grid minor minorcount=1;
	
	TITLE "Change in Efflux Over Time (% efflux / 4 hours)";

RUN;


1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 PROC SGPLOT data=data_02_output;
70 series x=time y=mean_efflux / lineattrs=(thickness=3px) group=group
71 markers markerattrs=(size=10pt) DATALABEL DATALABELATTRS=(Color=grey Family="Arial" Size=12
72 Style=Italic Weight=Bold);
73
74 yaxis
75 values=(5 to 15 BY 5) valuesformat=4.2 label='Efflux (% efflux / 4 hours)'
___
22
200
ERROR 22-322: Syntax error, expecting one of the following: a name, a format name.
ERROR 200-322: The symbol is not recognized and will be ignored.
76 labelattrs=(size=12pt weight=bold color=gray33)
77 valueattrs=(size=12pt weight=bold color=gray33)
78 offsetmin=0 offsetmax=0 grid minor minorcount=1
79 ;
80
81 xaxis
82 values=(1 to 3 BY 1) label='Visit Number'
83 labelattrs=(size=12pt weight=bold color=gray33)
84 valueattrs=(size=12pt weight=bold color=gray33)
85 offsetmin=0 offsetmax=0 grid minor minorcount=1;
86
87 TITLE "Change in Efflux Over Time (% efflux / 4 hours)";
88
89 RUN;


NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SGPLOT used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 487.43k
OS Memory 26020.00k
Timestamp 11/20/2021 12:12:27 AM
Step Count 191 Switch Count 1
Page Faults 0
Page Reclaims 51
Page Swaps 0
Voluntary Context Switches 7
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0

90
91 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
101

 

Data:

Obs Time Group mean_efflux std_efflux
1 1 A 9.56125 2.70856
2 1 B 9.50000 2.29669
3 2 A 9.40800 2.59412
4 2 B 9.54333 2.29103
5 3 A 9.30400 2.66388
6 3 B 9.68250 1.76490

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

How about setting valuesformat = data and using a format statement to set the actual format. 

 

Like this

 

data data_02_output;
input Obs Time Group $ mean_efflux std_efflux;
datalines;
1 1 A 9.56125 2.70856
2 1 B 9.50000 2.29669
3 2 A 9.40800 2.59412
4 2 B 9.54333 2.29103
5 3 A 9.30400 2.66388
6 3 B 9.68250 1.76490
;

PROC SGPLOT data=data_02_output;
   series x=time y=mean_efflux / lineattrs=(thickness=3px) group=group
      markers markerattrs=(size=10pt) DATALABEL DATALABELATTRS=(Color=grey Family="Arial" Size=12
        Style=Italic Weight=Bold);

   yaxis
    values=(5 to 15 BY 5) valuesformat = data label='Efflux (% efflux / 4 hours)'
    labelattrs=(size=12pt weight=bold color=gray33)
    valueattrs=(size=12pt weight=bold color=gray33)
    offsetmin=0 offsetmax=0 grid minor minorcount=1
    ;
    
   xaxis
    values=(1 to 3 BY 1) label='Visit Number'
    labelattrs=(size=12pt weight=bold color=gray33)
    valueattrs=(size=12pt weight=bold color=gray33)
    offsetmin=0 offsetmax=0 grid minor minorcount=1;
   
   TITLE "Change in Efflux Over Time (% efflux / 4 hours)";

   format mean_efflux 8.1;
RUN;

View solution in original post

1 REPLY 1
PeterClemmensen
Tourmaline | Level 20

How about setting valuesformat = data and using a format statement to set the actual format. 

 

Like this

 

data data_02_output;
input Obs Time Group $ mean_efflux std_efflux;
datalines;
1 1 A 9.56125 2.70856
2 1 B 9.50000 2.29669
3 2 A 9.40800 2.59412
4 2 B 9.54333 2.29103
5 3 A 9.30400 2.66388
6 3 B 9.68250 1.76490
;

PROC SGPLOT data=data_02_output;
   series x=time y=mean_efflux / lineattrs=(thickness=3px) group=group
      markers markerattrs=(size=10pt) DATALABEL DATALABELATTRS=(Color=grey Family="Arial" Size=12
        Style=Italic Weight=Bold);

   yaxis
    values=(5 to 15 BY 5) valuesformat = data label='Efflux (% efflux / 4 hours)'
    labelattrs=(size=12pt weight=bold color=gray33)
    valueattrs=(size=12pt weight=bold color=gray33)
    offsetmin=0 offsetmax=0 grid minor minorcount=1
    ;
    
   xaxis
    values=(1 to 3 BY 1) label='Visit Number'
    labelattrs=(size=12pt weight=bold color=gray33)
    valueattrs=(size=12pt weight=bold color=gray33)
    offsetmin=0 offsetmax=0 grid minor minorcount=1;
   
   TITLE "Change in Efflux Over Time (% efflux / 4 hours)";

   format mean_efflux 8.1;
RUN;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 2660 views
  • 1 like
  • 2 in conversation