BookmarkSubscribeRSS Feed
P5C768
Obsidian | Level 7

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.

15 REPLIES 15
ballardw
Super User

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

P5C768
Obsidian | Level 7

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;

AncaTilea
Pyrite | Level 9

I did, too.

And there are several errors in the proc template.

However, just the proc gmap gives the attached map.

ballardw
Super User

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

AncaTilea
Pyrite | Level 9

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

P5C768
Obsidian | Level 7

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?

AncaTilea
Pyrite | Level 9

have you tried my suggestion?

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


??

AncaTilea
Pyrite | Level 9

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.

ballardw
Super User

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.

DanH_sas
SAS Super FREQ

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

GraphGuy
Meteorite | Level 14

How are you running SAS? ...

DMS (Display Management System).

Batch.

EG.

Stored Process.

Connect.

Other?

P5C768
Obsidian | Level 7

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

, I am using EG.

ChrisHemedinger
Community Manager

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

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Cynthia_sas
SAS Super FREQ

...and after the quit;

ods html close; OR ods _all_ close;

cynthia

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
  • 15 replies
  • 3377 views
  • 1 like
  • 7 in conversation