Data visualization with SAS programming

Color Ramp for GMAP

Reply
Frequent Contributor
Posts: 84

Color Ramp for GMAP

I've been trying to add a color ramp to a map using the suggested coding from:

41776 - Create a map with colors defined from a color ramp

However, I can't get anything other then the basic green choro (so the proc template I use it not being applied).  I tried adding a goptions device=actximg; statement to remove a warning, but I still can only get the basic green.  I'm on 9.2.  Any ideas?  I've just been using a predefined set of 5 colors instead, but a color ramp would work much better since I may not always have 5 levels.  Thanks.

Grand Advisor
Posts: 9,713

Re: Color Ramp for GMAP

Your template and map producing code will likely help a diagnosis.

Frequent Contributor
Posts: 84

Re: Color Ramp for GMAP

I'm using the code from the link attached above:

proc template;

   define style styles.colorramp;

   parent=styles.default;

   /* Define a lighter and darker shade of blue for the starting and ending colors. */

   style twocolorramp / startcolor=cxF3F7FE endcolor=cx6497EB;

   /* When there are fewer than 3 response levels, GraphData1 and GraphData2

      are used for the colors */

   style graphdata1 from graphdata1 / color=cxF3F7FE;

   style graphdata2 from graphdata2 / color=cx6497EB;

   end;

run;

/* Reference the style using the STYLE= option on the ODS destination statement */

goptions device=actximg;

ods listing style=styles.colorramp;

title 'Map with colors defined from a color ramp';

proc gmap data=maps.us map=maps.us;

   id state;

   choro state;

run;

quit;

Super Contributor
Posts: 543

Re: Color Ramp for GMAP

I did, too.

And there are several errors in the proc template.

However, just the proc gmap gives the attached map.

Grand Advisor
Posts: 9,713

Re: Color Ramp for GMAP

No errors in the template when I ran it. Likely a difference in options or settings between installations.

Super Contributor
Posts: 543

Re: Color Ramp for GMAP

Could be.

this is the error I get when I run the code as is (I like the exclamation mark at the end of the error!!!!)

1    proc template;

NOTE: Writing HTML Body file: sashtml.htm

2

3       define style styles.colorramp;

4

5       parent=styles.default;

6

7

8

9

10

11      /* Define a lighter and darker shade of blue for the starting and ending colors. */

12

13      style twocolorramp / startcolor=cxF3F7FE endcolor=cx6497EB;

14

15

16

17

18

19      /* When there are fewer than 3 response levels, GraphData1 and GraphData2

20

21         are used for the colors */

22

23      style graphdata1 from graphdata1 / color=cxF3F7FE;

24

25      style graphdata2 from graphdata2 / color=cx6497EB;

26

27      end;

ERROR: Template 'Styles.Colorramp' was unable to write to template store!

28

29   run;

NOTE: PROCEDURE TEMPLATE used (Total process time):

      real time           0.46 seconds

      cpu time            0.37 seconds

WARNING: Errors were produced.

NOTE: The SAS System stopped processing this step because of errors.

30

Frequent Contributor
Posts: 84

Re: Color Ramp for GMAP

When I remove the device = actximg and replace it with goptions reset=all; I get "ERROR: Device was not specified."

How can I direct the html output to have the assigned style?

Super Contributor
Posts: 543

Re: Color Ramp for GMAP

have you tried my suggestion?

ODS PATH work.templat(update) sasuser.templat(read) sashelp.tmplmst(read);


??

Super Contributor
Posts: 543

Re: Color Ramp for GMAP

Apparently there is an error on read/write permissions, so you need to run this little piece of code before you run your original code:

ODS PATH work.templat(update) sasuser.templat(read) sashelp.tmplmst(read);

Good luck and let us know if it work!

Smiley Wink


Anca.

Grand Advisor
Posts: 9,713

Re: Color Ramp for GMAP

When problems pop up with graphic output I start with:

goptions reset=all;

I ran your code minus the device = actximg and get 6 shades of blue in the LISTING output and I am running SAS 9.2.

However in HTML output in the results windo I get the color scheme set by my default style. If you are looking at the results window and it is HTM output that could be the problem, the HTML destination didn't get assigned the style.

SAS Super FREQ
Posts: 864

Re: Color Ramp for GMAP

The problem here is that you are trying to use the style on the LISTING destination. The ACTXIMG device it not supported for LISTING. Try using that device with ODS HTML instead and see you get the expected result.

Hope this helps!

Dan

SAS Employee
Posts: 963

Re: Color Ramp for GMAP

How are you running SAS? ...

DMS (Display Management System).

Batch.

EG.

Stored Process.

Connect.

Other?

Frequent Contributor
Posts: 84

Re: Color Ramp for GMAP

, yes I tried that as well , with no luck.

, I am using EG.

Community Manager
Posts: 2,599

Re: Color Ramp for GMAP

If you're using EG, you won't easily get your graph output via the LISTING destination (as the code example shows).

Assuming that you are using HTML as your output destination in EG, try this:

ODS PATH work.templat(update) sasuser.templat(read) sashelp.tmplmst(read);

proc template;

   define style styles.colorramp;

   parent=styles.default;

   /* Define a lighter and darker shade of blue for the starting and ending colors. */

   style twocolorramp / startcolor=cxF3F7FE endcolor=cx6497EB;

   /* When there are fewer than 3 response levels, GraphData1 and GraphData2

      are used for the colors */

   style graphdata1 from graphdata1 / color=cxF3F7FE;

   style graphdata2 from graphdata2 / color=cx6497EB;

   end;

run;

/* forcing to PNG for now, you can change if you need to */

goptions dev=png;

/* Reference the style using the STYLE= option on the ODS destination statement */

/* piggy-back on the already-open HTML destination used by EG */

ods html(id=eghtml) style=styles.colorramp;

title 'Map with colors defined from a color ramp';

proc gmap data=maps.us map=maps.us;

   id state;

   choro state;

run;

quit;

Chris

SAS Super FREQ
Posts: 8,643

Re: Color Ramp for GMAP

...and after the quit;

ods html close; OR ods _all_ close;

cynthia

Post a Question
Discussion Stats
  • 15 replies
  • 1280 views
  • 1 like
  • 7 in conversation