I want to make a graph showing the effect of both wind speed and wind direction on black carbon concentration - so basically x axis = wind speed y axis = wind direction, and the more red the higher BC concentration etc...
I think I can use proc gam or proc loess.. but not to sure how to code it
Thanks in advance!
What you are showing is a simple rectangular heat map by speed and direction. This can be done using SAS 9.40M3 SGPLOT HEATMAP or HEATMAPPARM. I used SASHELP.HEART to do an example, changed the axes. It would be more intuitive if the direction was circular.
%let gpath='.';
%let dpi=150;
ods html close;
ods listing image_dpi=&dpi gpath=&gpath;
/*--Replicate data > 1Million obs--*/
data heart;
set sashelp.heart(keep=systolic diastolic cholesterol);
output;
do i=1 to 200;
systolic=systolic*(1+0.05*(ranuni(2)-0.5));
diastolic=diastolic*(1+0.05*(ranuni(2)-0.5));
cholesterol=cholesterol*(1+0.05*(ranuni(2)-0.5));
output;
end;
run;
title 'BC Concentration by Wind Speed and Direction';
proc sgplot data=heart(where=(systolic < 250 and diastolic < 150));
heatmap x=systolic y=diastolic / colorresponse=cholesterol
colorstat=mean colormodel=(white green yellow red)
nxbins=100 nybins=60 name='a';
gradlegend 'a' / title='';
xaxis display=(novalues noticks) min=100 max=200 label='Wind Direction';
yaxis display=(novalues noticks) min=50 max=125 label='Wind Speed';
run;
In PROC SPLOT you can just use a LOESS statement or a PBSPLINE statement to overlay a nonparametric curve on a scatter plot. (You can also use the REG statement for a parametric curve.)
For example:
proc sgplot data=sashelp.enso;
pbspline x=year y=pressure; /* also draws scatter plot */
loess x=year y=pressure / nomarkers; /* uses PRESEARCH option */
run;
For more control, you can use SAS procedures. See the article "How to automatically select a smooth curve for a scatter plot in SAS."
When the real data contains geographical elements like direction, or the data is cyclical, a polar graph can be very useful.
http://blogs.sas.com/content/graphicallyspeaking/2012/04/09/simpler-is-better/
Ideally you would want a radar chart where angle represents wind direction, radius represents wind speed, and color represents geometric mean black carbon concentration. That would be nice!
Anybody up to the challenge?
Yes that's exactly what I want actually.. Something like polarplot in R...
If you can include some sample data with the appropriate columns and a picture of what you are looking for, you may elicit some suggestions.
Columns would include - BC concentration, wind speed, and wind direction OR BC concentration, wind direction, and altitude etc.
So different colors will show BC conc, and x-axis wind direction, and y-axis wind speed...
Can SAS do this?
What you are showing is a simple rectangular heat map by speed and direction. This can be done using SAS 9.40M3 SGPLOT HEATMAP or HEATMAPPARM. I used SASHELP.HEART to do an example, changed the axes. It would be more intuitive if the direction was circular.
%let gpath='.';
%let dpi=150;
ods html close;
ods listing image_dpi=&dpi gpath=&gpath;
/*--Replicate data > 1Million obs--*/
data heart;
set sashelp.heart(keep=systolic diastolic cholesterol);
output;
do i=1 to 200;
systolic=systolic*(1+0.05*(ranuni(2)-0.5));
diastolic=diastolic*(1+0.05*(ranuni(2)-0.5));
cholesterol=cholesterol*(1+0.05*(ranuni(2)-0.5));
output;
end;
run;
title 'BC Concentration by Wind Speed and Direction';
proc sgplot data=heart(where=(systolic < 250 and diastolic < 150));
heatmap x=systolic y=diastolic / colorresponse=cholesterol
colorstat=mean colormodel=(white green yellow red)
nxbins=100 nybins=60 name='a';
gradlegend 'a' / title='';
xaxis display=(novalues noticks) min=100 max=200 label='Wind Direction';
yaxis display=(novalues noticks) min=50 max=125 label='Wind Speed';
run;
thank you! I haven't tried it out with my data, but think it will work-
Here is a more intuitive visual for directional data.
http://blogs.sas.com/content/graphicallyspeaking/2016/07/02/polar-graph/
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.