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.
Your template and map producing code will likely help a diagnosis.
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;
I did, too.
And there are several errors in the proc template.
However, just the proc gmap gives the attached map.
No errors in the template when I ran it. Likely a difference in options or settings between installations.
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
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?
have you tried my suggestion?
ODS PATH work.templat(update) sasuser.templat(read) sashelp.tmplmst(read);
??
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!
Anca.
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.
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
How are you running SAS? ...
DMS (Display Management System).
Batch.
EG.
Stored Process.
Connect.
Other?
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
...and after the quit;
ods html close; OR ods _all_ close;
cynthia
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.