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

Hello,

 

I need to create a CBSA map of the US - I started with a map with just the CBSA lines drawn on and then annotated state lines onto it, so I'm not using (and can't use) one of the SAS MAP. generated datasets for this. My problem is that for whatever reason the map is coming out on its side so California is at the top of the page and the East Cost is at the bottom rather than being left-right. If I restrict my input datasets to only print one state (i.e. a map with the state border and CBSA lines for a single state rather than the whole country), it comes out okay and is oriented correctly. The map of the entire country doesn't look like it is distorted or not to scale in any other sense; it's just on its side. I am wondering if there is an easy way to simply rotate this map by 90 degrees? I already tried GOPTIONS ROTATE, but that did nothing.

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
osi814
Obsidian | Level 7

As an update to this, I was able to figure it out! The problem was that I wasn't treating Alaska, Hawaii, and Puerto Rico separately, so including them was throwing off the projection. Thanks again for your reply!

View solution in original post

3 REPLIES 3
ballardw
Super User

Do you get any interesting messages in the log? Does this happen without the annotate dataset?

 

You might post the GMAP code for the whole map and what you ran for the single state map.

osi814
Obsidian | Level 7

Thank you for your reply! This does not happen without the annotate dataset, so if I map just the CBSA map without the state lines for the whole country, it is oriented correctly. I have pasted my code below. The only difference between it and the single state code is that I created subsets of the two initial datastates to restrict to a single FIPS code. Other than that, the code for the two maps is identical.

 

/*******************************/

/* ADD GROUP INDICATOR TO CBSA_BOUNDARY SET TO BE USED LATER */

/*****************************/

DATA CBSA_IN; SET CBSA_BOUNDARY;

GROUP=2; RUN;

 

/* SUBSET THE US STATE DATA */

/* NOTE: RETAIN THE LATITUDE AND LONGITUDE VALUES THAT ARE IN EASTLONG DEGREES */

/* RENAME TO X AND Y*/

DATA STATE_IN; SET MAPSGFK.US_STATES (DROP=X Y);

RENAME LONG=X LAT=Y;

GROUP=1;

KEEP GROUP STATE SEGMENT LONG LAT;

RUN;

 

/******************************/

/* "PROJECT" THE COORDINATES */

/******************************/

DATA COMBINE; SET STATE_IN CBSA_IN; RUN;

PROC GPROJECT DATA = COMBINE OUT=COMBINE_P

EASTLONG DEGREES;

ID GROUP SEGMENT;

RUN;

/* SEPARATE PROJECTED DATASETS */

DATA STATE (DROP=NAME) CBSA; SET COMBINE_P;

IF GROUP=1 THEN OUTPUT STATE;

ELSE IF GROUP=2 THEN OUTPUT CBSA;

DROP GROUP; /*NOTE: GROUP VARIABLE WAS CREATED FOR THIS STEP OF SEPARATING THE DATASETS*/

RUN;

 

/**************************************************/

/* CREATE ANNOTATE DATASET (DRAWS STATE BORDER) */

/**************************************************/

PROC SORT DATA = STATE; BY STATE SEGMENT; RUN;

DATA WORK.ANNO;

LENGTH COLOR FUNCTION $ 8;

RETAIN XSYS YSYS "2" COLOR "BLACK" SIZE 1.5 WHEN "A" FX FY FUNCTION;

SET WORK.STATE;

BY STATE SEGMENT;

IF FIRST.SEGMENT THEN DO;

FUNCTION = "MOVE";

FX = X;

FY = Y;

END;

ELSE IF FUNCTION ^= " " THEN DO;

IF X = . THEN DO;

X = FX;

Y = FY;

OUTPUT;

FUNCTION = " ";

END;

ELSE FUNCTION = 'DRAW';

END;

IF FUNCTION ^= " " THEN DO;

OUTPUT;

IF LAST.SEGMENT THEN DO;

X = FX;

Y = FY;

OUTPUT;

END;

END;

KEEP COLOR FUNCTION XSYS YSYS SIZE WHEN X Y;

RUN;

 

/****************/

/* CREATE MAP */

/****************/

GOPTIONS XPIXELS=1500 YPIXELS=1500;

PROC GMAP

DATA=CBSA MAP=CBSA ANNO=ANNO;

ID NAME;

CHORO NAME / DISCRETE;

TITLE "CBSAs";

RUN;

TITLE;

 

 

 

osi814
Obsidian | Level 7

As an update to this, I was able to figure it out! The problem was that I wasn't treating Alaska, Hawaii, and Puerto Rico separately, so including them was throwing off the projection. Thanks again for your reply!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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