BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Whitlea
Obsidian | Level 7

SAS 9.4

 

Hello, 

 

I am attempting to create a county heat map with count and county name included on the map.  I think that my variable county is clashing with maps.counties variable but I cant tell.  These are the errors that are coming up:


Some observations were discarded when charting County. 

 

By variables are not properly sorted on data set work.mtcontycnt.

 

the data set work.mtmap may be incomplete. 

 

Also I was wondering if there is a procedure in SAS that will categorize my count groups for me that makes sense statistically? 

Attached is the code.

 

Thanks So Much for the Help!!

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@Whitlea wrote:

SAS 9.4

 

 

Some observations were discarded when charting County. 

 

 


Not an error. This occurs when using the same data set for Data= and MAP= because the DATA will have multiple observations for each ID value. The DATA= data set is expected to have one observation per Id (geographical region) unless you request a summary statistic to display per region.

 


By variables are not properly sorted on data set work.mtcontycnt.

Any procedure or data set that uses a BY statement requires the variables to be sorted in the order indicated on the BY statement.

Use proc sort to sort your work.mtcontycnt set to match. I am assuming this occurs with your MERGE.

 

You could use your CNT variable directly, no reason to create additional variables. Just use a different format.

proc format ; 
value cntgrp 
.         = '<30'
 0 -< 30  = '<30' 
30 - 60   = '30-60' 
61 - 91   = '61-91' 
92 - 122  = '92-122' 
123 - 153 = '123-153'
154 - 184 = '154-184'
185 - 210 = '185-210'; 

That way if you decide to change the ranges then you only need to modify the format and not go back through a data step to add a new, or replace the existing, variable.

 


Also I was wondering if there is a procedure in SAS that will categorize my count groups for me that makes sense statistically? 

 


You would have to describe what you mean by "makes sense statistically". 

As in which statistic, what it measures and such.

 

You might use the Choro option LEVELS to create a number region grouping values instead of your format.

 

 

View solution in original post

4 REPLIES 4
Whitlea
Obsidian | Level 7

FYI "maps" on Ln 95 wasn't supposed to be there and was removed.

ballardw
Super User

@Whitlea wrote:

SAS 9.4

 

 

Some observations were discarded when charting County. 

 

 


Not an error. This occurs when using the same data set for Data= and MAP= because the DATA will have multiple observations for each ID value. The DATA= data set is expected to have one observation per Id (geographical region) unless you request a summary statistic to display per region.

 


By variables are not properly sorted on data set work.mtcontycnt.

Any procedure or data set that uses a BY statement requires the variables to be sorted in the order indicated on the BY statement.

Use proc sort to sort your work.mtcontycnt set to match. I am assuming this occurs with your MERGE.

 

You could use your CNT variable directly, no reason to create additional variables. Just use a different format.

proc format ; 
value cntgrp 
.         = '<30'
 0 -< 30  = '<30' 
30 - 60   = '30-60' 
61 - 91   = '61-91' 
92 - 122  = '92-122' 
123 - 153 = '123-153'
154 - 184 = '154-184'
185 - 210 = '185-210'; 

That way if you decide to change the ranges then you only need to modify the format and not go back through a data step to add a new, or replace the existing, variable.

 


Also I was wondering if there is a procedure in SAS that will categorize my count groups for me that makes sense statistically? 

 


You would have to describe what you mean by "makes sense statistically". 

As in which statistic, what it measures and such.

 

You might use the Choro option LEVELS to create a number region grouping values instead of your format.

 

 

Whitlea
Obsidian | Level 7

Thanks so much for the levels suggestion!

ballardw
Super User

@Whitlea wrote:

Thanks so much for the levels suggestion!


While working out which Level you want you may want to turn on the RANGE option as well to show a legend with the values for each color.

 

I generally don't leave a final version that way as the Range tends to show the actual values and people are uncomfortable with not knowing where a value that isn't in the data might have gone.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 4 replies
  • 645 views
  • 0 likes
  • 2 in conversation