BookmarkSubscribeRSS Feed
SASSLICK001
Obsidian | Level 7

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.

 

SASSLICK001_0-1616544346793.png

 

6 REPLIES 6
JosvanderVelden
SAS Super FREQ
Something like a grouped barchart?

See example: https://robslink.com/SAS/democd17/fruit_info.htm

Best regards, Jos
PhilC
Rhodochrosite | Level 12

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?

SASSLICK001
Obsidian | Level 7
Hi : Thanks for the solutions. I have too many subjects in the data, is there any way I can limit the number of subjects per page and create a multi page report.
Ksharp
Super User
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;

SGPlot5.png

SASSLICK001
Obsidian | Level 7
thanks for the quick response appreciate it , instead of needle , how can we use the bar
Ksharp
Super User
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;

SGPlot.png

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 6 replies
  • 1105 views
  • 8 likes
  • 4 in conversation