BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
bd_user_10
Quartz | Level 8

Hi Everyone,

 

I have been trying to create a spatial distribution map within 5 data ranges. Can someone please help me to detect why that's not working? The data ranges are given in the proc format section. Here are the codes:

 

goptions reset=all border;

title "County-level social capital levels, 2005";

proc gproject
data=maps.Counties
out=allcounties;
where state ne 2 and state ne 15 and state ne 72;
id state county;
run;


proc format ;
value sk_
1 = '-3.9094 - -1.0853'
2 = '-1.0852 - -0.5139'
3 = '-0.5138 - 0.0916'
4 = '0.0917 - 0.9486'
5 = '0.9487 - 14.2963'
;
run;


pattern1 v=s c=grayff;
pattern2 v=s c=grayaa;
pattern3 v=s c=graybb;
pattern4 v=s c=graycc;
pattern5 v=s c=graydd;

 

proc gmap
data=temp.social_capital_2005
map=allcounties all density=5;
id state county;
choro sk ;
format sk sk_.;
run;
quit;

 

I have also provided the data in the data section. Thanks in advance for your help.

 

The final output should be very similar to the 2005 sample in the link. https://aese.psu.edu/nercrd/community/social-capital-resources/us-maps-showing-county-social-capital...

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Your format for SK_ is incorrect. You attempt to use values of 1, 2, 3,4 and 5 for SK when the actual values are quite different.

Also, your indicated ranges overlap which is a no-no in general. Formats use value on the LEFT side of the = and display the value on the right side.

 

Try this format and see if things are better.

proc format ;
value sk_
 -3.9094 - -1.0852 = '-3.9094 - -1.0852'
 -1.0852< - -0.5138= '-1.0853 - -0.5138'
 -0.5138< - 0.0916 = '-0.5139 - 0.0916'
 0.0916< - 0.9486  = '0.0917 - 0.9486'
 0.9486< - high    = '0.9487 - 14.2963'
;
run;

the < in the ranges indicates an open interval, so does not overlap with the previous and provides rules for if there is an actual value of -1.08524.

 


@bd_user_10 wrote:

Hi Everyone,

 

I have been trying to create a spatial distribution map within 5 data ranges. Can someone please help me to detect why that's not working? The data ranges are given in the proc format section. Here are the codes:

 

goptions reset=all border;

title "County-level social capital levels, 2005";

proc gproject
data=maps.Counties
out=allcounties;
where state ne 2 and state ne 15 and state ne 72;
id state county;
run;


proc format ;
value sk_
1 = '-3.9094 - -1.0853'
2 = '-1.0852 - -0.5139'
3 = '-0.5138 - 0.0916'
4 = '0.0917 - 0.9486'
5 = '0.9487 - 14.2963'
;
run;


pattern1 v=s c=grayff;
pattern2 v=s c=grayaa;
pattern3 v=s c=graybb;
pattern4 v=s c=graycc;
pattern5 v=s c=graydd;

 

proc gmap
data=temp.social_capital_2005
map=allcounties all density=5;
id state county;
choro sk ;
format sk sk_.;
run;
quit;

 

I have also provided the data in the data section. Thanks in advance for your help.

 

The final output should be very similar to the 2005 sample in the link. https://aese.psu.edu/nercrd/community/social-capital-resources/us-maps-showing-county-social-capital...


 

View solution in original post

2 REPLIES 2
ballardw
Super User

Your format for SK_ is incorrect. You attempt to use values of 1, 2, 3,4 and 5 for SK when the actual values are quite different.

Also, your indicated ranges overlap which is a no-no in general. Formats use value on the LEFT side of the = and display the value on the right side.

 

Try this format and see if things are better.

proc format ;
value sk_
 -3.9094 - -1.0852 = '-3.9094 - -1.0852'
 -1.0852< - -0.5138= '-1.0853 - -0.5138'
 -0.5138< - 0.0916 = '-0.5139 - 0.0916'
 0.0916< - 0.9486  = '0.0917 - 0.9486'
 0.9486< - high    = '0.9487 - 14.2963'
;
run;

the < in the ranges indicates an open interval, so does not overlap with the previous and provides rules for if there is an actual value of -1.08524.

 


@bd_user_10 wrote:

Hi Everyone,

 

I have been trying to create a spatial distribution map within 5 data ranges. Can someone please help me to detect why that's not working? The data ranges are given in the proc format section. Here are the codes:

 

goptions reset=all border;

title "County-level social capital levels, 2005";

proc gproject
data=maps.Counties
out=allcounties;
where state ne 2 and state ne 15 and state ne 72;
id state county;
run;


proc format ;
value sk_
1 = '-3.9094 - -1.0853'
2 = '-1.0852 - -0.5139'
3 = '-0.5138 - 0.0916'
4 = '0.0917 - 0.9486'
5 = '0.9487 - 14.2963'
;
run;


pattern1 v=s c=grayff;
pattern2 v=s c=grayaa;
pattern3 v=s c=graybb;
pattern4 v=s c=graycc;
pattern5 v=s c=graydd;

 

proc gmap
data=temp.social_capital_2005
map=allcounties all density=5;
id state county;
choro sk ;
format sk sk_.;
run;
quit;

 

I have also provided the data in the data section. Thanks in advance for your help.

 

The final output should be very similar to the 2005 sample in the link. https://aese.psu.edu/nercrd/community/social-capital-resources/us-maps-showing-county-social-capital...


 

bd_user_10
Quartz | Level 8
Thanks that helped.
Need to add '/ discrete' after choro sk.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 568 views
  • 1 like
  • 2 in conversation