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

Hi,

My data looks like 

Sally_Caffrey_0-1704362105078.png

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 ?

a.png

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Amethyst | Level 16

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:

yabwon_0-1704366542146.png

 

 

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

1 REPLY 1
yabwon
Amethyst | Level 16

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:

yabwon_0-1704366542146.png

 

 

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 1535 views
  • 3 likes
  • 2 in conversation