Data visualization with SAS programming

sas GRAPH Hbar with repeating period

Accepted Solution Solved
Reply
Contributor
Posts: 26
Accepted Solution

sas GRAPH Hbar with repeating period

Dear all,

i would like to perform the graph in attachments.

I thought that it was possible usng Hbar with sgplot, but it does not.

The problem is that some period are repeating (in this case "Home").

Do you think that it was possible with SAS v9.4? What procedure?

Thanks for your support

 


GraphswithHBAR.png

Accepted Solutions
Solution
‎06-29-2017 09:16 AM
Super User
Super User
Posts: 7,720

Re: sas GRAPH Hbar with repeating period

Maybe have a look through this blog:

http://blogs.sas.com/content/graphicallyspeaking/

 

Has loads of examples of all types of graphs.

View solution in original post


All Replies
Solution
‎06-29-2017 09:16 AM
Super User
Super User
Posts: 7,720

Re: sas GRAPH Hbar with repeating period

Maybe have a look through this blog:

http://blogs.sas.com/content/graphicallyspeaking/

 

Has loads of examples of all types of graphs.

Contributor
Posts: 26

Re: sas GRAPH Hbar with repeating period

Thank you

SAS Super FREQ
Posts: 706

Re: sas GRAPH Hbar with repeating period

I suggest to use the HIGHLOW plot statement, you have to prepare the data accordingly.

 

See below for an example, that gives you some ideas:

data highlow;
  infile cards dlm="," dsd missover;
  input
    patient : $32. low high type $ labelPoint labelValue $
  ;
  cards;
patient1 someDate,0,20,hospital,10,20
patient1 someDate,20,40,ward,,
patient1 someDate,40,50,hospital,,
patient1 someDate,50,52,home,,
patient1 someDate,52,55,ward,53.5,abc
patient2 01jan2010-25sep2010,0,25,hospital,,
patient2 01jan2010-25sep2010,25,45,home,,
patient2 01jan2010-25sep2010,45,46,ward,,
;

proc sgplot data=highlow;
  highlow y=patient low=low high=high / type=bar group=type;
  text y=patient x=labelPoint text=labelValue / position=center;
  yaxis type=discrete fitpolicy=splitalways;
run;
Contributor
Posts: 26

Re: sas GRAPH Hbar with repeating period

Thank you,

i try to put the legend in top of the graph and one line with this sentence:

keylegend / position=top  down=1;

But now i have Patient with different type and still on two rows for legends.

Can you help me?

 

SAS Super FREQ
Posts: 706

Re: sas GRAPH Hbar with repeating period

Add the NAME= option to your plot statements, then in the KEYLEGEND statement you can say for which plot statements you would like to have a legend.

 

Sample:

proc sgplot data=highlow;
  highlow y=patient low=low high=high / type=bar group=type name="hl";
  text y=patient x=labelPoint text=labelValue / position=center name="txt";
  yaxis type=discrete fitpolicy=splitalways;
  keylegend "hl" / position=top  down=1 ;
run;

The placement might have something to do with space that is available, try to make your graph bigger.

Contributor
Posts: 26

Re: sas GRAPH Hbar with repeating period

Thank you again!

It's perfect.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 251 views
  • 0 likes
  • 3 in conversation