DATA Step, Macro, Functions and more

digits of the values PROC GMAP

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

digits of the values PROC GMAP

Hello,

I am using gmap procedures to produce maps of the estimates of a model. SAS by default generates the range of these estimates and I can manage the levels but I could be able to manage the digits "decimals" of the estimates. I want to show only 2-digits in the values of the legend.
is there a way to add it to the code?

I appreciate any help.

thank you


here is my code
%macro map(data=,var=);
goptions reset=all;
proc gmap data=&data map=results all ;
id gc;
choro &var / legend=legend1 LEVELS=5;
legend1 position=( bottom right inside ) offset=(1.2cm ,0cm ) shape=bar(2,1) across=1 mode=PROTECT label=none / value=(h=0.8 f=swissb justify=left);
run;
quit;
%mend map;


Accepted Solutions
Solution
‎06-13-2018 06:09 PM
Super User
Posts: 13,523

Re: digits of the values PROC GMAP

I would start by applying a format to the variable that displays the with the desired appearance.

An example where I make an generic data set to actually display something and two versions of a minimal Gmap call to demonstrate the difference a format can make:

 

proc sql;
   create table work.statedata as
   select statecode, rand('uniform') as val
   from (select  distinct statecode from maps.us)
   ;
quit;

proc gmap data=work.statedata
          map=maps.us
;
   id statecode;
   choro val/levels=5;
run;
quit;


proc gmap data=work.statedata
          map=maps.us
;
   id statecode;
   choro val/levels=5;
   format val f4.2;
run;
quit;

I might suggest using a custom format as the above example is likely to generate end points that appear in multiple levels and/or have gaps.

 

Here's a brief example:

proc format library=work;
value mylev
0    - 0.2 = ' 0 - 0.20'
0.2 <- 0.4 = '0.2 < 0.4'
0.4 <- 0.6 = '0.4 < 0.6'
0.6 <- 0.8 = '0.6 < 0.8'
0.8 <- 1.0 = '0.8 < 1'
;
run;
proc gmap data=work.statedata
          map=maps.us
;
   id statecode;
   choro val/discrete;
   format val mylev.;
run;
quit;

Notice use of discrete instead of levels. The above has an additional advantage that you could change the groupings just by either changing the definition of the format or using a different format and not having to adjust the number of levels. This does change to using a discrete color system which would follow pattern definitions instead of a color ramp.

 

View solution in original post


All Replies
PROC Star
Posts: 2,348

Re: digits of the values PROC GMAP

Needs not totally clear, and an example would be welcome, but have you tried:

- Assigning a format ?

- Rounding the value ?

 

New Contributor
Posts: 3

Re: digits of the values PROC GMAP

Hello @ChrisNZ,

 

I appreciate your response. I do not know how to round within the code. Is it possible inside the code or should I round the values of the outputs first?

 

I want to map specific outputs of a regression model e.g., residuals, please find the legend attached. however i want the values to be rounded to only 2-digits (i.e., 0.53-0.67, 0.67-0.73, 0.73-0.80, 0.80-0.88)

 

Thank you

Solution
‎06-13-2018 06:09 PM
Super User
Posts: 13,523

Re: digits of the values PROC GMAP

I would start by applying a format to the variable that displays the with the desired appearance.

An example where I make an generic data set to actually display something and two versions of a minimal Gmap call to demonstrate the difference a format can make:

 

proc sql;
   create table work.statedata as
   select statecode, rand('uniform') as val
   from (select  distinct statecode from maps.us)
   ;
quit;

proc gmap data=work.statedata
          map=maps.us
;
   id statecode;
   choro val/levels=5;
run;
quit;


proc gmap data=work.statedata
          map=maps.us
;
   id statecode;
   choro val/levels=5;
   format val f4.2;
run;
quit;

I might suggest using a custom format as the above example is likely to generate end points that appear in multiple levels and/or have gaps.

 

Here's a brief example:

proc format library=work;
value mylev
0    - 0.2 = ' 0 - 0.20'
0.2 <- 0.4 = '0.2 < 0.4'
0.4 <- 0.6 = '0.4 < 0.6'
0.6 <- 0.8 = '0.6 < 0.8'
0.8 <- 1.0 = '0.8 < 1'
;
run;
proc gmap data=work.statedata
          map=maps.us
;
   id statecode;
   choro val/discrete;
   format val mylev.;
run;
quit;

Notice use of discrete instead of levels. The above has an additional advantage that you could change the groupings just by either changing the definition of the format or using a different format and not having to adjust the number of levels. This does change to using a discrete color system which would follow pattern definitions instead of a color ramp.

 

New Contributor
Posts: 3

Re: digits of the values PROC GMAP

Hi @ballardw,

 

Thank you for your help, it works.

☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 167 views
  • 1 like
  • 3 in conversation