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
Onyx | Level 15

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
Onyx | Level 15

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



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