Graphics Programming

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

Hi,

 

I'm a begginer at sas graph programming and I need to create a line graph with xaxis that shows patient visits and yaxis that show lab test results. Visit consits of 1st,8th and 15th visit and for one patient visit=end of treatment (EOT). I need to present this EOT  at the end of xaxis as a dot and not connected to line graph.

 

my code

 


proc sgplot data=lb;
series x=vis y=result / group=usubjid grouplc=armcd break
transparency=0.7 lineattrs=(pattern=solid);
xaxis label="Timepoint" ;
Yaxis values=(0 to 30 by 2) label="arm";
keylegend / type=linecolor title="";
run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@Jedrzej wrote:
scatter is good but the dot is connected to the graph line (probably because I use the same variable for x=vis).

when I create two separate variables for EOT (x and y) it is good but the dot appears at the begging of the graph and i want it at the end.

I missed that you want to set the original Y value to missing for the EOT observations. That happens when there is no data to actually test code against.

data example;
   input x y1 y2 gv;
datalines;
1 1 . 1
2 2 . 1
3 3 . 1
4 . 4 1
1 2 . 2
2 3 . 2
3 4 . 2
4 . 6 2
;

proc sgplot data=example;
   series x=x y=y1/group=gv;
   scatter x=x y=y2 /group=gv markerattrs=(symbol=circlefilled);
run;

 

View solution in original post

3 REPLIES 3
ballardw
Super User

Data is helpful.

 

Likely the easiest is to create another variable with the value you need for just that point, same xaxis variable with appropriate value, new y axis variable with the same range of values. Then use a SCATTER plot to overlay that on the series plot. You would not want your current Yaxis variable to have that value anymore.

 

The code would look something like:

proc sgplot data= NEWPLOTDATASET ;
series x=vis y=result / group=usubjid grouplc=armcd break
transparency=0.7 lineattrs=(pattern=solid);

scatter x=vis y=EOTvariable/ group=usubjid markerattrs=(symbol=circlefilled)
;
xaxis label="Timepoint" ;
Yaxis values=(0 to 30 by 2) label="arm";
keylegend / type=linecolor title="";
run;

There are options in the Markerattrs to control size if the defaults are too big or small. You may want the JITTER option on the SCATTER if the scatter "dots" overlap or hide each other because of similar values. That will make small adjustments from the actual x,y values so the symbols appear slightly apart.

 

Jedrzej
Obsidian | Level 7
scatter is good but the dot is connected to the graph line (probably because I use the same variable for x=vis).

when I create two separate variables for EOT (x and y) it is good but the dot appears at the begging of the graph and i want it at the end.
ballardw
Super User

@Jedrzej wrote:
scatter is good but the dot is connected to the graph line (probably because I use the same variable for x=vis).

when I create two separate variables for EOT (x and y) it is good but the dot appears at the begging of the graph and i want it at the end.

I missed that you want to set the original Y value to missing for the EOT observations. That happens when there is no data to actually test code against.

data example;
   input x y1 y2 gv;
datalines;
1 1 . 1
2 2 . 1
3 3 . 1
4 . 4 1
1 2 . 2
2 3 . 2
3 4 . 2
4 . 6 2
;

proc sgplot data=example;
   series x=x y=y1/group=gv;
   scatter x=x y=y2 /group=gv markerattrs=(symbol=circlefilled);
run;

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 3 replies
  • 2209 views
  • 0 likes
  • 2 in conversation