Data visualization with SAS programming

Rotating map with PROC GMAP

Accepted Solution Solved
Reply
Contributor
Posts: 20
Accepted Solution

Rotating map with PROC GMAP

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!


Accepted Solutions
Solution
‎01-07-2016 02:35 PM
Contributor
Posts: 20

Re: Rotating map with PROC GMAP

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


All Replies
Grand Advisor
Posts: 9,699

Re: Rotating map with PROC GMAP

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.

Contributor
Posts: 20

Re: Rotating map with PROC GMAP

[ Edited ]

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;

 

 

 

Solution
‎01-07-2016 02:35 PM
Contributor
Posts: 20

Re: Rotating map with PROC GMAP

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!

Post a Question
Discussion Stats
  • 3 replies
  • 461 views
  • 0 likes
  • 2 in conversation