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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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