I downloaded a "US_COUNTIES" SAS dataset from:
https://support.sas.com/rnd/datavisualization/mapsonline/html/gfkmaps_94m5.html
because it includes updated Alaska state-county FIPS over the "USCOUNTY" SAS dataset available in the SAS "maps" library.
Specific link
Unfortunately, I cannot figure out how to:
1) gproject this new US_COUNTIES data such that Alaska and Hawaii appear below California and New Mexico, and
2) how to change this "Miller2" projection in "US_COUNTIES" to something that better resembles what I have attached (2nd image below).
First, when I split up and try to project just the CONUS (states), using the following code, I get this error:
** now move AK and HI to below CA and NM for mapping;
**************** http://support.sas.com/kb/42/426.html ;
/* Since we want to move Alaska, Hawaii, and Puerto Rico under */
/* the continental U.S., we need to separate their coordinates */
/* so they can be projected separately. */
** xrefs.us_counties2017 is the same as “US_COUNTIES” direct download from SAS with the following edits:
/* if state=2 and county=270 then county = 158; *Wade Hampton Census Area to Kusilvak AK; */
/* if state=46 and county=113 then county = 102; *Shannon to Oglala SD; */
data states alaska hawaii;
set xrefs.us_counties2017(where=(state < 57)); *maps.states;
select;
when (state=2) output alaska;
when (state=15) output hawaii;
otherwise output states;
end;
run;
proc gproject data=states out=stproj project=miller2;
id state county;
run;
NOTE: The MILLER2 projection is experimental.
ERROR: At least one value is out of range for polar radian coordinates. Data might already be
projected, or might be in degrees instead of radians.
ERROR: Expected range is (-3.141592654, 3.1415926536) for X and (-1.570796327, 1.5707963268) for
Y.
ERROR: Actual range is (24482.484872, 26479.767739) for X and (200.21604878, 1149.9364232) for Y.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 873304 observations read from the data set WORK.STATES.
New Has the correct AK FIPS, but yucky projection: <pic1>
Old map (bad AK FIPS, but the projection I want with AK/HI below the contiguous US): <pic2>
I’d be happy to send all (115.8MB) of the US_COUNTIES SAS dataset, or just a subset if it helps.
By default, Proc Gproject uses the X & Y variables, and it assumes they are in radians, and the x value is "westlong".
I'm guessing the new map you downloaded has projected values in the X & Y, and therefore gproject is balking on them.
The new maps we've been shipping with SAS lately have unprojected values in Lat & Long variables, and are in degrees (rather than radians), and the longitude is in "eastlong" (rather than "westlong"). Therefore you'll probably need to specify those options with gproject, such as ...
Proc gproject data=my_map out=my_map latlong eastlong degrees ...
Here's an example I wrote, to convert the mapsgfk US county map into the traditional SAS county map, with Alaska & Hawaii moved and resized ...
http://robslink.com/SAS/democd97/uscounties_info.htm
http://robslink.com/SAS/democd97/uscounties.htm
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
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.
Ready to level-up your skills? Choose your own adventure.