BookmarkSubscribeRSS Feed
☑ This topic is solved. 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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 833 views
  • 0 likes
  • 2 in conversation