How can i draw following graph using sas? Any ideas would be appreciated. 001, 002 are patient numbers, the colored lines are a criterial presenting for each patient.
A "Needle" plot: SAS Help Center: Syntax: PROC SGPLOT NEEDLE Statement. I've implemented graphs like this using a scatter plot; using points, which I make small or invisible, then I use error bars, without "feet", with the same size as the y coordinate.
The colors look random. Would you be assigning colors to the needles based on your given data?
data have;
set sashelp.heart;
id+1;
if _n_=4 then stop;
keep diastolic height weight id;
format id z3.;
run;
proc transpose data=have out=want;
by id;
var diastolic height weight;
run;
data want;
set want;
col1=-col1;
run;
proc sgplot data=want;
needle x=id y=col1/group=_name_ groupdisplay=cluster clusterwidth=0.2 x2axis;
x2axis type=discrete valuesformat=z3.;
run;
data have;
set sashelp.heart;
id+1;
if _n_=4 then stop;
keep diastolic height weight id;
format id z3.;
run;
proc transpose data=have out=want;
by id;
var diastolic height weight;
run;
data want;
set want;
col1=-col1;
run;
proc sgplot data=want;
vbar id/response=col1 group=_name_ groupdisplay=cluster clusterwidth=0.2 x2axis;
x2axis type=discrete valuesformat=z2.;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.