BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Anita_n
Pyrite | Level 9

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?

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
proc sgplot data=have;
vbar drug/  response=dosis group=num_of_pat groupdisplay=cluster;
run;
--
Paige Miller

View solution in original post

15 REPLIES 15
PaigeMiller
Diamond | Level 26

What message do you want to the graph to provide the viewer?

 

 

--
Paige Miller
Anita_n
Pyrite | Level 9

The number of patients who received a certain drug and the dosis they received

PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
Anita_n
Pyrite | Level 9

Do you mean something like this

proc sgplot data=have;
vbar dosis /  response=num_of_pat group=drug groupdisplay=cluster;
run;
PaigeMiller
Diamond | Level 26
proc sgplot data=have;
vbar drug/  response=dosis group=num_of_pat groupdisplay=cluster;
run;
--
Paige Miller
Anita_n
Pyrite | Level 9

Thank you, I think I can go with that.

Anita_n
Pyrite | Level 9

@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

PaigeMiller
Diamond | Level 26

So you want two bars for Cefalexin when num_of_pat=1 and one more bar when num_of_pat=2?

--
Paige Miller
Anita_n
Pyrite | Level 9

Yes please

PaigeMiller
Diamond | Level 26

I don't know how to do that. I don't even think it is possible.

--
Paige Miller
Anita_n
Pyrite | Level 9

okay, thankyou

PaigeMiller
Diamond | Level 26

Maybe you want the average to be the height of the bar instead of the sum?

--
Paige Miller
Anita_n
Pyrite | Level 9

No, not the average

ballardw
Super User

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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 15 replies
  • 735 views
  • 1 like
  • 3 in conversation