Hi,
My data looks like
I want draw a series plot where column "value" is y-axis and column "actual_x" is x-axis, and display the x-axis values using "dummy_x" value. Here is my code:
proc sgplot data=a2;
series x=actual_x y=value /markers;
xaxis label='timepoints' values=(0 0.25 0.5 1 1.5 2 3 4 6 8 12 18 24);
run;
But the values option did not work, the plot looks as below. How to display the x-axis values as 0 0.25 0.5 1 1.5 2 3 4 6 8 12 18 24 ?
What you provided is not data, it's a print screen... Next time provide real data in a data step format
Here are some data "concocted" for the tests:
data a2;
input dummy_x @@;
value+ranuni(123);
actual_x = dummy_x + (ranuni(123)-0.5)*0.01;
actual_x = round(actual_x,0.001);
cards;
0 0.25 0.5 1 1.5 2 3 4 6 8 12 18 24
run;
proc print;
run;
To get your labels do the following:
/* prepare values and they labels */
proc sql noprint;
select
actual_x format best32.,
quote(cats(dummy_x))
into
:myvalues separated by ", ",
:myvaluesDisp separated by " "
from
a2
order by
actual_x
;
quit;
/* see in the log */
%put &=myvalues.;
%put &=myvaluesDisp.;
ODS GRAPHICS / WIDTH=1200px; /* make the picture big enough */
proc sgplot data=a2;
series x=actual_x y=value / markers;
xaxis
label='timepoints'
VALUES=(&myvalues.) /* values (actual_x) */
VALUESDISPLAY=(&myvaluesDisp.) /* what to be displayed (dummy_x) */
FITPOLICY=STAGGER /* fit pollicy to fit vaslues to display */
VALUEATTRS=(Size=6) /* smaller letters */
;
run;
The result (for my example data) is:
Bart
What you provided is not data, it's a print screen... Next time provide real data in a data step format
Here are some data "concocted" for the tests:
data a2;
input dummy_x @@;
value+ranuni(123);
actual_x = dummy_x + (ranuni(123)-0.5)*0.01;
actual_x = round(actual_x,0.001);
cards;
0 0.25 0.5 1 1.5 2 3 4 6 8 12 18 24
run;
proc print;
run;
To get your labels do the following:
/* prepare values and they labels */
proc sql noprint;
select
actual_x format best32.,
quote(cats(dummy_x))
into
:myvalues separated by ", ",
:myvaluesDisp separated by " "
from
a2
order by
actual_x
;
quit;
/* see in the log */
%put &=myvalues.;
%put &=myvaluesDisp.;
ODS GRAPHICS / WIDTH=1200px; /* make the picture big enough */
proc sgplot data=a2;
series x=actual_x y=value / markers;
xaxis
label='timepoints'
VALUES=(&myvalues.) /* values (actual_x) */
VALUESDISPLAY=(&myvaluesDisp.) /* what to be displayed (dummy_x) */
FITPOLICY=STAGGER /* fit pollicy to fit vaslues to display */
VALUEATTRS=(Size=6) /* smaller letters */
;
run;
The result (for my example data) is:
Bart
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!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.