<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Together at Last: Spatial Analysis and SAS Mapping? Not quite yet. in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Together-at-Last-Spatial-Analysis-and-SAS-Mapping-Not-quite-yet/m-p/804185#M22699</link>
    <description>&lt;P&gt;Esteemed Advisers:&lt;/P&gt;
&lt;P&gt;I'm trying to implement an analog to the spatial mapping program that was developed and demonstrated by D. Massengill and A. Kolovos (SAS Global Forum 2012 Paper 284-2012, "Together at Last: Spatial Analysis and SAS Mapping").&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've been successful in replicating their results using their example dataset and codes. I have not succeeded when using my own dataset and their codes.&lt;/P&gt;
&lt;P&gt;Specifically, the logfile shows multiple messages of the type:&lt;/P&gt;
&lt;P&gt;NOTE: PROBLEM IN OBSERVATION 1 -&lt;BR /&gt;DATA SYSTEM REQUESTED, BUT VALUE IS NOT ON GRAPH 'X' -23707.7&lt;BR /&gt;DATA SYSTEM REQUESTED, BUT VALUE IS NOT ON GRAPH 'Y' 9944.658&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;X and Y variables are the appropriate longitude and latitude values as called for by the code. But the associated numbers in the logfile are meaningless to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Attached is the code that produces the result above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm hoping that someone familiar with the paper by Massengill and Kolovos might take a look at what's happening here and can help me out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance for any assistance,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Gene&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 25 Mar 2022 21:33:25 GMT</pubDate>
    <dc:creator>genemroz</dc:creator>
    <dc:date>2022-03-25T21:33:25Z</dc:date>
    <item>
      <title>Together at Last: Spatial Analysis and SAS Mapping? Not quite yet.</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Together-at-Last-Spatial-Analysis-and-SAS-Mapping-Not-quite-yet/m-p/804185#M22699</link>
      <description>&lt;P&gt;Esteemed Advisers:&lt;/P&gt;
&lt;P&gt;I'm trying to implement an analog to the spatial mapping program that was developed and demonstrated by D. Massengill and A. Kolovos (SAS Global Forum 2012 Paper 284-2012, "Together at Last: Spatial Analysis and SAS Mapping").&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've been successful in replicating their results using their example dataset and codes. I have not succeeded when using my own dataset and their codes.&lt;/P&gt;
&lt;P&gt;Specifically, the logfile shows multiple messages of the type:&lt;/P&gt;
&lt;P&gt;NOTE: PROBLEM IN OBSERVATION 1 -&lt;BR /&gt;DATA SYSTEM REQUESTED, BUT VALUE IS NOT ON GRAPH 'X' -23707.7&lt;BR /&gt;DATA SYSTEM REQUESTED, BUT VALUE IS NOT ON GRAPH 'Y' 9944.658&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;X and Y variables are the appropriate longitude and latitude values as called for by the code. But the associated numbers in the logfile are meaningless to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Attached is the code that produces the result above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm hoping that someone familiar with the paper by Massengill and Kolovos might take a look at what's happening here and can help me out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance for any assistance,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Gene&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 21:33:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Together-at-Last-Spatial-Analysis-and-SAS-Mapping-Not-quite-yet/m-p/804185#M22699</guid>
      <dc:creator>genemroz</dc:creator>
      <dc:date>2022-03-25T21:33:25Z</dc:date>
    </item>
    <item>
      <title>Re: Together at Last: Spatial Analysis and SAS Mapping? Not quite yet.</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Together-at-Last-Spatial-Analysis-and-SAS-Mapping-Not-quite-yet/m-p/804202#M22700</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The message you are getting is typically associated with requesting a plot point, such as annotate data, that is outside the bounds of the MAP data set. You can check the bounds on your map data set by&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc means data=&amp;lt;your map dataset name goes here&amp;gt; max min;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var x y;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;Which gets for this example:&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Means: Summary statistics" cellspacing="0" cellpadding="3"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c m header" scope="col"&gt;Variable&lt;/TH&gt;
&lt;TH class="c m header" scope="col"&gt;Label&lt;/TH&gt;
&lt;TH class="c m header" scope="col"&gt;Maximum&lt;/TH&gt;
&lt;TH class="c m header" scope="col"&gt;Minimum&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l stacked_cell data"&gt;
&lt;TABLE border="0" width="100%" cellspacing="0" cellpadding="3"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l data top_stacked_value"&gt;X&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l data bottom_stacked_value"&gt;Y&lt;/TH&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/TH&gt;
&lt;TH class="l stacked_cell data"&gt;
&lt;TABLE border="0" width="100%" cellspacing="0" cellpadding="3"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l data top_stacked_value"&gt;Projected Longitude from Radians&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l data bottom_stacked_value"&gt;Projected Latitude from Radians&lt;/TH&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/TH&gt;
&lt;TD class="r stacked_cell data"&gt;
&lt;TABLE border="0" width="100%" cellspacing="0" cellpadding="3"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data top_stacked_value"&gt;0.0351414&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data bottom_stacked_value"&gt;0.1421963&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/TD&gt;
&lt;TD class="r stacked_cell data"&gt;
&lt;TABLE border="0" width="100%" cellspacing="0" cellpadding="3"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data top_stacked_value"&gt;-0.3721635&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data bottom_stacked_value"&gt;-0.1938140&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One suspects the map data set they used in the original example either had a different projection or missed the step to project your data from lat/long to x/y or convert to radians. You may have to watch the sign of the results when you get done.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which will display the maximum and minimum values of the x and y variables. One strongly suspects that min of x is larger than -23707 and that the max of Y is less than 9944 in the map set you are using.&lt;/P&gt;
&lt;P&gt;Run the same code on your annotate data set&lt;/P&gt;</description>
      <pubDate>Sat, 26 Mar 2022 00:12:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Together-at-Last-Spatial-Analysis-and-SAS-Mapping-Not-quite-yet/m-p/804202#M22700</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-26T00:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: Together at Last: Spatial Analysis and SAS Mapping? Not quite yet.</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Together-at-Last-Spatial-Analysis-and-SAS-Mapping-Not-quite-yet/m-p/804268#M22701</link>
      <description>&lt;P&gt;Yes indeed, failure to properly project coordinates was the source of the problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Thanks for your help,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Gene&lt;/P&gt;</description>
      <pubDate>Sat, 26 Mar 2022 15:10:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Together-at-Last-Spatial-Analysis-and-SAS-Mapping-Not-quite-yet/m-p/804268#M22701</guid>
      <dc:creator>genemroz</dc:creator>
      <dc:date>2022-03-26T15:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Together at Last: Spatial Analysis and SAS Mapping? Not quite yet.</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Together-at-Last-Spatial-Analysis-and-SAS-Mapping-Not-quite-yet/m-p/804550#M22702</link>
      <description>&lt;P&gt;Here's a slightly modified version of the code, that uses lat/long values until the end, and then projects them to projected x/y values at the very end. The original SGF paper example used maps.states and deals with converting between degrees and radians, whereas I use mapsgfk.us_states and keep the coordinates in degrees until I project them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro make_anno(annodata,inputdata,
   rwidth,rdepth,lcolor,fcolor,solid,center,tipvar);
 data &amp;amp;annodata;
  length function $8 color $ 12 style $20 ;
  retain xsys ysys '2' hsys '3' when 'a' size .7;
  /* default grid block size variables, if not passed in (in degrees) */
  width=1; depth=1;
  %if (&amp;amp;inputdata ^= ) %then %do;
    set &amp;amp;inputdata;
  %end;
  %if (&amp;amp;solid = 'Y') %then %do;
     style='solid';
  %end;
  %else %do; 
     style='empty';
  %end;
  line=1;
    /* optional arguments */
  %if (&amp;amp;rwidth ^= ) %then %do;
    width=&amp;amp;rwidth;
  %end;
  %if (&amp;amp;rdepth ^= ) %then %do;
    depth=&amp;amp;rdepth;
  %end;
  
  /* optional tool tips */
  %if (&amp;amp;tipvar ^= ) %then %do;
    html= 'title=' || quote("&amp;amp;tipvar" ||'=' || trim(left(&amp;amp;tipvar)) );
  %end;
  start_long =long;
  start_lat= lat;

  /*** create the rectangle ***/
  /* coordinates of the rectangle */
  function='POLY';   color=&amp;amp;fcolor;
  long=start_long-width; lat=start_lat+depth; output; /* start position */
  function='POLYCONT'; 
  long=start_long+width; lat=start_lat+depth; output; 
  long=start_long+width; lat=start_lat-depth; output;
  long=start_long-width; lat=start_lat-depth; output;

run;
%mend;


/* get min &amp;amp; max values, to use for scaling colors */
%macro get_minmax(inds,varname);
%global minval;
%global maxval;
data tempmm; set &amp;amp;inds END=lastob; 
   retain maxval -999999999;
   retain minval  999999999;
   if &amp;amp;varname &amp;lt;= minval then 
      minval=&amp;amp;varname;
   else if &amp;amp;varname &amp;gt;= maxval then
      maxval=&amp;amp;varname;

   if (lastob = 1) then do;
	  output;
          call symput("minval",minval);
          call symput("maxval",maxval);
	  end;
run;
%mend;


%macro draw_map(mapdata,respdata, annodata, id, choro, name, dev,  mapcolor, htmlvar);
   GOPTIONS reset=all;
   GOPTIONS CBACK=white;
   GOPTIONS DEVICE=&amp;amp;dev xpixels=700 ypixels=500;
   ODS LISTING CLOSE;

   %if ((&amp;amp;mapcolor ne ) and (&amp;amp;mapcolor = "N")) %then %do;
     pattern v=me c=CX000000 r=100;
   %end;
   %else %do;
     pattern v=s c=CXE9E8DC r=100;
   %end;

   %if (&amp;amp;htmlvar ^= ) %then %do;
      %let htmlv=html=&amp;amp;htmlvar;
   %end;
   %else %do;
      %let htmlv=;
   %end;
   goptions border;

   proc gmap map=&amp;amp;mapdata anno=&amp;amp;annodata data=&amp;amp;respdata all;  
        id &amp;amp;id;  
        choro &amp;amp;choro /nolegend &amp;amp;htmlv;
   run;
   quit;
%mend;


data my_data;
  infile datalines dsd truncover;
  input orientation:$10. Target:$15. k:32. station:$8. lat:8.1 long:8.1 xpos1:32. ypos1:32. ksum:32. ksumk:32.;
  format lat 8.1 long 8.1;
datalines;
45/35,360/-30/100,20,USL000,34.5,-110.7,360,-30,3,23
45/35,390/-30/100,18,USL000,34.5,-110.4,390,-30,3,21
45/35,420/-60/100,20,USL000,34.2,-110.1,420,-60,4,24
45/35,450/-60/100,20,USL000,34.2,-109.7,450,-60,4,24
45/35,450/-30/100,19,USL000,34.5,-109.7,450,-30,3,22
45/35,480/-90/100,19,USL000,34.0,-109.4,480,-90,4,23
45/35,480/-60/100,19,USL000,34.2,-109.4,480,-60,4,23
45/35,480/-30/100,19,USL000,34.5,-109.4,480,-30,3,22
45/35,510/-90/100,19,USL000,34.0,-109.1,510,-90,4,23
45/35,540/-120/100,17,USL000,33.7,-108.8,540,-120,4,21
;;;;
run;

%let oildata=my_data;
%let predvar=ksumk;

%get_minmax(&amp;amp;oildata,&amp;amp;predvar);

/* set the color for each data point */
data &amp;amp;oildata; set &amp;amp;oildata; 
  length hx $2;

  /*make negative numbers green to black */
  /*the more negative the number, the greener */
  if (&amp;amp;predvar &amp;lt; 0) then do;
     cnum=(&amp;amp;predvar * (255/&amp;amp;minval));  /*scale colors */

	 /*Make sure we stay within the threshold values*/
	 if (cnum &amp;lt; 0) then cnum=0;
	 else if (cnum &amp;gt; 255) then cnum=255;
	 hx=put(cnum,hex2.);
	 /* Transparency for 9.3 and up*/
	 color="A00"||trim(left(hx))||"0099";

	 /* Pre-9.3 cannot use transparency ****
	 color="CX00"||trim(left(hx))||"00";
	 ***/
	 end;

  /* Make Positive values black to Red */
  /* Larger numbers are more red       */
  else do;
     cnum=(&amp;amp;predvar * (255/ &amp;amp;maxval));
	 /*Make sure we stay within the threshold values*/
	 if (cnum &amp;lt;= 0) then cnum=0;
	 else if (cnum &amp;gt; 255) then cnum=255;
	 hx=put(cnum,hex2.);
         /* Alpha-transparent colors */
	 color="A"||trim(left(hx))||"000099";
     end;
run;

%make_anno(annogrid,&amp;amp;oildata,.15,.15,color,color,'Y','N',&amp;amp;predvar);
run;

data mystates;
set mapsgfk.us_states (where=(statecode in ('TX' 'OK' 'KS' 'CO' 'NM' 'AZ' 'UT' 'NV' 'CA')));
run;

/* project the map and the annotate data using the same parameters */
proc gproject data=mystates out=mystates latlong eastlong degrees project=hammer parmout=parms;
id id;
run;
proc gproject data=annogrid out=annogrid latlong eastlong degrees parmin=parms parmentry=mystates;
id;
run;

%draw_map(mystates, mystates, annogrid,state,state,oil,png,"N");
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="map_grid.png" style="width: 812px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69880i633DD85B32650394/image-size/large?v=v2&amp;amp;px=999" role="button" title="map_grid.png" alt="map_grid.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 22:38:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Together-at-Last-Spatial-Analysis-and-SAS-Mapping-Not-quite-yet/m-p/804550#M22702</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2022-03-28T22:38:09Z</dc:date>
    </item>
  </channel>
</rss>

