Dear all,
if I have a data that looks like this.
data have;
infile datalines;
input num_of_pat drug $12. dosis ;
datalines;
1 Cefalexin 120
1 Calcipotriol 165
1 Folic acid 260
1 Piriton 300
1 Fentanyl 360
1 Folic acid 260
1 Co-beneldopa 356
1 Folic acid 267
2 Cefalexin 119
2 Fentanyl 354
1 Allopurinol 331
1 Folic acid 278
1 Cefalexin 113
1 Allopurinol 332
;
run;
proc sgplot data=have;
series x=dosis y=num_of_pat /group=drug;
run;
what is the best way to display this graphically: The problem is I have over 100 records and the num of patients ranges from 1 to 2 which makes it not easy to display this. Any idea?
proc sgplot data=have;
vbar drug/ response=dosis group=num_of_pat groupdisplay=cluster;
run;
What message do you want to the graph to provide the viewer?
The number of patients who received a certain drug and the dosis they received
I am thinking a clustered bar chart (VBAR) would make more sense to show the variable DOSIS. Horizontal axis is drug, with separate bars for NUM_OF_PAT 1 and 2.
Do you mean something like this
proc sgplot data=have;
vbar dosis / response=num_of_pat group=drug groupdisplay=cluster;
run;
proc sgplot data=have;
vbar drug/ response=dosis group=num_of_pat groupdisplay=cluster;
run;
Thank you, I think I can go with that.
@PaigeMiller why are the bars summed up per group. For example Cefalexin occurs three times. I don't want the 3 values summed up but displayed side by side
So you want two bars for Cefalexin when num_of_pat=1 and one more bar when num_of_pat=2?
Yes please
I don't know how to do that. I don't even think it is possible.
okay, thankyou
Maybe you want the average to be the height of the bar instead of the sum?
No, not the average
I am not clear what the graph is supposed to explain or clarify. What does "dosis" measure?
This will draw a separate needle for each observation.
proc sgplot data=have; needle x=dosis y=num_of_pat /group=drug ; yaxis values= (0 to 3 by 1); run;
Should perhaps some values, such as your Allopurinol with Dosis = 331 and 332, really should be treated separately. But with a purpose for what this graph should explain...
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.