Hello SAS users,
my data are means from measurements that were taken before surgery and at regular interval after surgery. I would like to connect with a smooth line only the measurement taken after surgery. The means of measurements taken before surgery should have the same symbols as those following surgery but should be separated. Can I do this without juxtaposing 2 separately created graphs?
Thank you!
I posted my code below, although I am not sure that it can offer any further information to this problem.
proc sgplot data= &VB.overtime3 ;
Title "Perioperative levels of &VB";
styleattrs datacontrastcolors=(blue blue red red ) DATALINEPATTERNS=(solid shortdash solid shortdash )
datacolors=(blue blue red red) datasymbols=(circlefilled circlefilled squarefilled squarefilled);
xaxis type=discrete;
series x=level y=&VB.mean_lev /smoothconnect
MARKERS markerattrs=(size=9) LINEATTRS = (THICKNESS = 2)group = &G;
keylegend/ valueattrs=(SIZE=12);
xaxis type=discrete;
scatter x=level y=&VB.mean_lev /
markerattrs=(size=0)
yerrorlower=&VB.LCLM_lev
yerrorupper=&VB.UCLM_lev group = &G;
YAXIS LABEL = "&VB (mg/dl)" valueattrs=(SIZE=12) labelattrs=(SIZE=12 weight=bold) ;
XAXIS LABEL = 'TIME' valueattrs=(SIZE=12) labelattrs=(SIZE=12 weight=bold);
format level level.;
run;
@Giampaolo wrote:
Hello SAS users,
my data are means from measurements that were taken before surgery and at regular interval after surgery. I would like to connect with a smooth line only the measurement taken after surgery. The means of measurements taken before surgery should have the same symbols as those following surgery but should be separated. Can I do this without juxtaposing 2 separately created graphs?
Thank you!
Yes you can, but you likely need to modify your data.
I would probably just create some new variables such that you have two series of data and then use a SCATTER statement for the data before the surgery and SERIES for the data after the surgery date.
Split data into new variables.
data want;
set have;
if date > surgery_date then do;
x=new_x;
y=new_y;
call missing(x,y);
end;
run;
It may be as simple as having the two groups of data points (before and after) as separate variables plotted with two scatter statements.
If you showed some data that would help.
@Giampaolo wrote:
Hello SAS users,
my data are means from measurements that were taken before surgery and at regular interval after surgery. I would like to connect with a smooth line only the measurement taken after surgery. The means of measurements taken before surgery should have the same symbols as those following surgery but should be separated. Can I do this without juxtaposing 2 separately created graphs?
Thank you!
Yes you can, but you likely need to modify your data.
I would probably just create some new variables such that you have two series of data and then use a SCATTER statement for the data before the surgery and SERIES for the data after the surgery date.
Split data into new variables.
data want;
set have;
if date > surgery_date then do;
x=new_x;
y=new_y;
call missing(x,y);
end;
run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.
Ready to level-up your skills? Choose your own adventure.