Data visualization with SAS programming

How do I plot diary data using SGPLOT HIGHLOW

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

How do I plot diary data using SGPLOT HIGHLOW

I have plots I created in SGPLOT to show the use of three product forms over time.  There is a plot for each panelist and all of the products used show up as a rectangle.  There are three product types - sometimes they overlap and there can be many uses.  The data are formatted such that each row is a product used and each subject can have any number of uses (usually < 20). 

 

datascreenshot.png

 

I used SGPLOT highlow to basically draw a series of rectangles for each product used and the type of product on the y-axis but the code is no longer working and I am unsure what changed.  The data is the same as before but now I only see a single line at the end of the plot rather than rectangles.  What would cause that?

 

proc sgplot data=use noautolegend nocycleattrs;
  highlow y=form low=on high=off / 
				group=abs2				type=bar 
          		barwidth=0.8 
				lineattrs=(color=black pattern=1)
				name='Form'
				x2axis;
 
  *--Assign dummy plot to create independent X2 axis--*;
  scatter x=day_int y=form /  markerattrs=(size=0);

regimen plot.png

 


Accepted Solutions
Solution
2 weeks ago
Esteemed Advisor
Posts: 5,399

Re: How do I plot diary data using SGPLOT HIGHLOW

Hard to tell without seeing your current graph and your data. But looking at your code, nothing guarantees that your X1 and X2 axes will line up properly. It would be a lot safer to convert your on and off dates into days since beginning and drop the dummy plot.

PG

View solution in original post


All Replies
Super User
Posts: 13,066

Re: How do I plot diary data using SGPLOT HIGHLOW

I am not sure I am understanding what you mean by " I only see a single line at the end of the plot rather than rectangles".

I don't see anything that jumps out as "being a single line". The only thing I see are black lines that look a lot like they would come from almost overlapping areas.

Solution
2 weeks ago
Esteemed Advisor
Posts: 5,399

Re: How do I plot diary data using SGPLOT HIGHLOW

Hard to tell without seeing your current graph and your data. But looking at your code, nothing guarantees that your X1 and X2 axes will line up properly. It would be a lot safer to convert your on and off dates into days since beginning and drop the dummy plot.

PG
New Contributor
Posts: 4

Re: How do I plot diary data using SGPLOT HIGHLOW

This worked - I created a lag variable for the day interval variable and used those in the highlow.  Thank you!

New Contributor
Posts: 4

Re: How do I plot diary data using SGPLOT HIGHLOW

Apologies - I only included what the plot used to look like.  It now looks like this:

 

badplot.png

Contributor
Posts: 62

Re: How do I plot diary data using SGPLOT HIGHLOW

Hi, hard to understand what you really want in this. Seem like a Gantt chart to me. Hard to see what has gone wrong withut the data in a better form. Maby a vector plot can work better.

New Contributor
Posts: 4

Re: How do I plot diary data using SGPLOT HIGHLOW

Posted in reply to PaalNavestad

I tried a GANTT plot but it puts each product use on its own line vs showing all the uses of a form in a row (like in the first picture).  I wasn't able to figure out what to change to make GANTT work.  Thank you for the suggestion.

Contributor
Posts: 62

Re: How do I plot diary data using SGPLOT HIGHLOW

There is a keep at same line example. It is a long time since I used that but there is a good example for a salesman visiting several cities.

 

This is an example using two gant viewers in VA. The top one has over lapping dates as you had some challenges with using high-low. If you have VA available that might be the best solution, because of mouse over etc. The gantt procedure is a bit quarrelsome to get nics.

va_gant.PNG

☑ This topic is solved.

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

Discussion stats
  • 7 replies
  • 149 views
  • 1 like
  • 4 in conversation