Hi all,
I am struggling with the most efficient way to graph my raw data along with a model curve. Here is the scenario:
I have raw data that look somewhat like this with multiple entities (ID) and essentially Y variable values for a 5 hour intervals for a ~30 24-hour periods that is unique for each ID. Note: Some of the 5 hr intervals cross the day boundary. For example, some start at 10PM to 2AM.
ID TIMESTAMP Date Time Y
1 03APR2015:00:00:00.000000 04/03/2015 00:00:00 3
1 03APR2015:01:00:00.000000 04/03/2015 01:00:00 2
1 03APR2015:02:00:00.000000 04/03/2015 02:00:00 1
1 03APR2015:03:00:00.000000 04/03/2015 03:00:00 1
1 03APR2015:04:00:00.000000 04/03/2015 04:00:00 0
1 04APR2015:00:00:00.000000 04/04/2015 00:00:00 0
1 04APR2015:01:00:00.000000 04/04/2015 01:00:00 0
1 04APR2015:02:00:00.000000 04/04/2015 02:00:00 3
1 04APR2015:03:00:00.000000 04/04/2015 03:00:00 0
1 04APR2015:04:00:00.000000 04/04/2015 04:00:00 2
. . .
. . .
. . .
2 03APR2015:05:00:00.000000 04/03/2015 05:00:00 0
2 03APR2015:06:00:00.000000 04/03/2015 06:00:00 2
2 03APR2015:07:00:00.000000 04/03/2015 07:00:00 1
2 03APR2015:08:00:00.000000 04/03/2015 08:00:00 1
2 03APR2015:09:00:00.000000 04/03/2015 09:00:00 1
. . .
. . .
. . .
I suggest use "BY=date;" The graphs should get separated by date, and only the real data range will be shown. Or use SGPANEL, with PANELBY date.
General comment - Including a full running program (with sample data) makes it easier to help. Also include the SAS version you are using.
Hi Sanjay,
How would the BY=date approach work for 5 hour intervals that span the day boundary? The example from my original post was :
"Some of the 5 hr intervals cross the day boundary. For example, some start at 10PM to 2AM."
Also, ideally, I would like 4 days per plot.
Is there an easy way to specify 3 separate x-axis breaks for each plot in 9.3? There would be ~2,3183 plots where the 3 x-axis breaks would be different for each plot.
Thank you,
Dan
Sanjay's BY-groiuping trick could still work for you. Create two indexing columns in your data. One index column where each unique index (1, 2, 3, etc.) is assigned to the observations you want to contain in each plot. The other index column should be the string column you mentioned that contains the intervals. Set OPTIONS NOBYLINE to prevent the BY information from showing up in a title. Then, just use the index column as your BY variable, and the interval index on the PANELBY statement of SGPANEL. It will look something like this:
proc sgpanel data=mydata;
by index;
panelby interval / layout=columnlattice uniscale=row onepanel;.
series x=xvar y=yvar;
run;
Hope this helps!
Dan
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.