BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
imsenny
Calcite | Level 5

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

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

9 REPLIES 9
Rick_SAS
SAS Super FREQ

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

 

 

Jay54
Meteorite | Level 14

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/

 

PGStats
Opal | Level 21

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
imsenny
Calcite | Level 5

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

Jay54
Meteorite | Level 14

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.

imsenny
Calcite | Level 5

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?

 

 

Jay54
Meteorite | Level 14

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;
imsenny
Calcite | Level 5

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

 

 

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
  • 9 replies
  • 3037 views
  • 4 likes
  • 4 in conversation