Data visualization with SAS programming

smooth function of wind direction & wind speed on BC concentration

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 15
Accepted Solution

smooth function of wind direction & wind speed on BC concentration

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!


Accepted Solutions
Solution
‎06-30-2016 06:53 PM
SAS Super FREQ
Posts: 1,086

Re: smooth function of wind direction & wind speed on BC concentration

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.

 

Heat_Map_SG.png

 

%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;

View solution in original post


All Replies
SAS Super FREQ
Posts: 3,420

Re: smooth function of wind direction & wind speed on BC concentration

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."

 

 

SAS Super FREQ
Posts: 1,086

Re: smooth function of wind direction & wind speed on BC concentration

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/

 

Respected Advisor
Posts: 4,609

Re: smooth function of wind direction & wind speed on BC concentration

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?

PG
Occasional Contributor
Posts: 15

Re: smooth function of wind direction & wind speed on BC concentration

Yes that's exactly what I want actually.. Something like polarplot in R...

SAS Super FREQ
Posts: 1,086

Re: smooth function of wind direction & wind speed on BC concentration

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.

Occasional Contributor
Posts: 15

Re: smooth function of wind direction & wind speed on BC concentration

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?

 

 

Solution
‎06-30-2016 06:53 PM
SAS Super FREQ
Posts: 1,086

Re: smooth function of wind direction & wind speed on BC concentration

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.

 

Heat_Map_SG.png

 

%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;
Occasional Contributor
Posts: 15

Re: smooth function of wind direction & wind speed on BC concentration

thank you! I haven't tried it out with my data, but think it will work-

 

 

SAS Super FREQ
Posts: 1,086

Re: smooth function of wind direction & wind speed on BC concentration

Here is a more intuitive visual for directional data.

http://blogs.sas.com/content/graphicallyspeaking/2016/07/02/polar-graph/

 

☑ This topic is SOLVED.

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

Discussion stats
  • 9 replies
  • 1208 views
  • 4 likes
  • 4 in conversation