BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PSIOT
SAS Employee

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
1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Maybe have a look through this blog:

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

 

Has loads of examples of all types of graphs.

PSIOT
SAS Employee

Thank you

BrunoMueller
SAS Super FREQ

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;
PSIOT
SAS Employee

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?

 

BrunoMueller
SAS Super FREQ

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.

PSIOT
SAS Employee

Thank you again!

It's perfect.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 6 replies
  • 1022 views
  • 0 likes
  • 3 in conversation