Data visualization with SAS programming

Proc GMAP Formats

Accepted Solution Solved
Reply
Contributor
Posts: 30
Accepted Solution

Proc GMAP Formats

Hello, I have the below program where I have created a map output.  I also created 4 patterns as well as 4 catagories in my Proc Format statement.  My question is, instead of assigning a pattern can I assign a color depending on the underlying value.  so for low - < .25 I would like this to always be green and so on, with the .75 - high always be red.  Thank you.

 

DATA WORK.MYMAP;

SET MAPSGFK.US;

WHERE STATECODE NOT IN ('AK', 'HI');

RUN;

 

*create format for map output;

PROC FORMAT;

VALUE ITP

low - < .25 = '< 25%'

.25 - < .50 = '25 - 49 %'

.50 - < .75 = '50 - 74%'

.75 - high = '> 75%'

;

RUN;

PATTERN1 V=S c=green;

PATTERN2 V=S c=yellow;

PATTERN3 V=S C=blue;

PATTERN4 V=S C=Red;

PATTERN5 V=MS c=lightgrey;

 

PROC GMAP DATA=WORK.SALESKPI_APPLICATION_OUT1 MAP=WORK.MYMAP ALL ;

BY LVL1_SALES_CHANNEL;

ID STATECODE;

BLOCK ITP_PD_PCT / DISCRETE WOUTLINE=1 COUTLINE=black CEMPTY=BLACK cblock=black blocksize=4 shape=cylinder

xview=0.75 yview=-1.0 zview=3.5;

label ITP_PD_PCT = 'ITP Past Due %';

FORMAT ITP_PD_PCT ITP.;

RUN;

QUIT;


Accepted Solutions
Solution
‎01-13-2017 08:29 AM
Super User
Posts: 11,118

Re: Proc GMAP Formats

How many different combinations are you going to deal with? If it is only a few then you may be able to make a macro that that takes as one of the parameters the appropriate format, which you would still need for the grouping and include code to check the format and assign the matching legend values.

 

Semi pseudocode of what I am thinking;

%macro mymap (dataset=, mapset=, mapvar=, mapvarfmt = );

%if %upcase(&Mapvarfmt) = ITP %then %do;
   PATTERN1 V=S c=green;
   PATTERN2 V=S c=yellow;
   PATTERN3 V=S C=blue;
   PATTERN4 V=S C=Red;
%end;

%if %upcase(&Mapvarfmt) = OTHFMT %then %do;
   PATTERN1 V=S c=green;
   PATTERN2 V=S c=yellow;
   PATTERN3 V=S C=Red;
%end;

/* the actual gmap code goes here*/
%mend;

/* call similar to */
%mymap (dataset=WORK.SALESKPI_APPLICATION_OUT1 , mapset=WORK.MYMAP , mapvar=ITP_PD_PCT , mapvarfmt = ITP)

Or maybe instead of the actual format name to assign the pattern statements a separate NumLegendLines parameter and have groups of pattern statements corresponding to 3, 4, 5, 6 or similar groups you might reuse. This would have the advantage of only needing to know the number breaks in your data to display if you use many formats with slightly different values between those upper and lower bounds.

 

View solution in original post


All Replies
Super User
Posts: 11,118

Re: Proc GMAP Formats

What I think you are asking is similar to the ATTRMAP attribute dataset for variables for SG graphing procedures to keep characterstics that can be "automatically" applied without defining them in each procedure call.

 

GMAP is basically the old device approach and does not support that approach. If the bounds don't change you can use the format you have already defined with multiple variables.

 

If you always want to use 4 colors, a custom ODS style could be created to modify the default colors  and would be used in the order of the PATTERN statements that you are currently defining but not attached to a specific range of values.

 

Or are you trying to have the color for those ranges when you may have more or fewer response categories?

 

You may need to be a bit more specific about what you are attempting to achieve.

Contributor
Posts: 30

Re: Proc GMAP Formats

Good Afternoon

Thank you for the feedback.  yes what I am trying to achieve is as you stated "trying to have the color for those ranges when you may have more or fewer response categories?". 

Contributor
Posts: 30

Re: Proc GMAP Formats

Good Afternoon

Thank you for the feedback. yes what I am trying to achieve is as you stated "trying to have the color for those ranges when you may have more or fewer response categories?".




Solution
‎01-13-2017 08:29 AM
Super User
Posts: 11,118

Re: Proc GMAP Formats

How many different combinations are you going to deal with? If it is only a few then you may be able to make a macro that that takes as one of the parameters the appropriate format, which you would still need for the grouping and include code to check the format and assign the matching legend values.

 

Semi pseudocode of what I am thinking;

%macro mymap (dataset=, mapset=, mapvar=, mapvarfmt = );

%if %upcase(&Mapvarfmt) = ITP %then %do;
   PATTERN1 V=S c=green;
   PATTERN2 V=S c=yellow;
   PATTERN3 V=S C=blue;
   PATTERN4 V=S C=Red;
%end;

%if %upcase(&Mapvarfmt) = OTHFMT %then %do;
   PATTERN1 V=S c=green;
   PATTERN2 V=S c=yellow;
   PATTERN3 V=S C=Red;
%end;

/* the actual gmap code goes here*/
%mend;

/* call similar to */
%mymap (dataset=WORK.SALESKPI_APPLICATION_OUT1 , mapset=WORK.MYMAP , mapvar=ITP_PD_PCT , mapvarfmt = ITP)

Or maybe instead of the actual format name to assign the pattern statements a separate NumLegendLines parameter and have groups of pattern statements corresponding to 3, 4, 5, 6 or similar groups you might reuse. This would have the advantage of only needing to know the number breaks in your data to display if you use many formats with slightly different values between those upper and lower bounds.

 

Contributor
Posts: 30

Re: Proc GMAP Formats

Thank you very much.  I will work with that and let you know how it turns out.  Again I greatly appreciate your guidance.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 224 views
  • 1 like
  • 2 in conversation