LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 1997, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 13 Oct 1997 14:16:12 +0100
Reply-To:     "Wolf F. Lesener" <wflesener@RZ.HU-BERLIN.DE>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         "Wolf F. Lesener" <wflesener@RZ.HU-BERLIN.DE>
Subject:      Re: graph: display cities on state map
Content-Type: text/plain; charset="iso-8859-1"

Hallo Wendy,

this is a problem I had a longer time ago too. My solution is a very heuristic. You need a well done atlas may be of Washington state. The method is to cover the SAS map of interest by a grid of lines and to do a visual estimation of the planar x,y coordinates. (ESTIMATE.SAS)

Then the estimated x,y coordinates are used to create an annotation file as usually. (CITIES.SAS)

I remember this method was described also in SAS Observations Journal. The No. I don't remember but it seems to me to be not a primary problem because I can send you an analogous SAS program:

%let mark=estimate.sas; GOPTIONS RESET=ALL DEVICE=WIN CBACK=WHITE CTEXT=BLACK; GOPTIONS KEYMAP=WINANSI DEVMAP=WINANSI; /* Deutschland + Österreich */ title c=black f=simplex h=5 pct 'Estimation of SAS Map Coordinates'; footnote c=black f=simplex h=.8 j=r "&mark ";

/* Please notice: Any SAS Map can be reduced by where clauses to an area of interest */ /* the example parameter set for USA is reduced to Washington state */

/* USA Deutschland Österreich */ %LET MAP =MAPS.USCOUNTY (WHERE=(STATE=53)); /* MAPS.GERMANY; maps.geraussw (where=(country=165)); */ %LET ID =COUNTY; /* ID; id; */ %LET GRID =.001; /* 100; 20; */ %LET FORMAT=5.2; /* 4.; 4.;

/* Extract the Extrems of X,Y in the given Map */ PROC UNIVARIATE DATA=&MAP NOPRINT; VAR X Y; OUTPUT MIN=XMIN YMIN MAX=XMAX YMAX; proc print; /* test print only */

/* Compute the starting and end points of the covering grid and assign it to macro variables */ DATA _NULL_; SET _LAST_; XMIN=&GRID*FLOOR(XMIN/&GRID); YMIN=&GRID*FLOOR(YMIN/&GRID); XMAX=&GRID*CEIL (XMAX/&GRID); YMAX=&GRID*CEIL (YMAX/&GRID); CALL SYMPUT('XMIN',TRIM(LEFT(PUT(XMIN,&FORMAT)))); CALL SYMPUT('YMIN',TRIM(LEFT(PUT(YMIN,&FORMAT)))); CALL SYMPUT('XMAX',TRIM(LEFT(PUT(XMAX,&FORMAT)))); CALL SYMPUT('YMAX',TRIM(LEFT(PUT(YMAX,&FORMAT)))); RUN; %put xmin=&xmin xmax=&xmax ymin=&ymin ymax=&ymax; /* test print only */

/* Compute and store all Grid lines in an annotate file */ DATA GRID; LENGTH FUNCTION COLOR $8; RETAIN XSYS YSYS HSYS ('2' '2' '4'); RETAIN SIZE (1); DO X=&XMIN TO &XMAX BY &GRID; IF MOD(FLOOR(X/&GRID),10) THEN COLOR='BLUE'; ELSE COLOR='ORANGE'; FUNCTION='MOVE'; Y=&YMIN; OUTPUT; FUNCTION='DRAW'; Y=&YMAX; OUTPUT; END; DO Y=&YMIN TO &YMAX BY &GRID; IF MOD(FLOOR(Y/&GRID),10) THEN COLOR='BLUE'; ELSE COLOR='ORANGE'; FUNCTION='MOVE'; X=&XMIN; OUTPUT; FUNCTION='DRAW'; X=&XMAX; OUTPUT; END;

/* Cover the Map of interest with the grid stored in the annotate file */ TITLE C=BLUE F=SWISSL H=1 "XMIN=&XMIN XMAX=&XMAX YMIN=&YMIN YMAX=&YMAX GRID=&GRID x &GRID"; PATTERN V=E R=999; PROC GMAP MAP =&MAP DATA=&MAP ANNO=_LAST_; ID &ID; CHORO &ID / DISCRETE COUTLINE=BLACK NOLEGEND; RUN; QUIT;

Wendy, it may be that you can circumvent the visual estimation step if you are able to perform geographic coordinates into SAS coordinates for the US map by a program. (For the Map of Germany this way was not a way to go because the given SAS map of Germany is already a projected map and the number of polygon points is to few. It means if we are reducing the area of interest to a single German Kreis (County) the borderline is very abstract and a lot of performed points are laying outside its area.) Following step generates a demofile and represents the noninteractive way to get the annotate file which draws the cities names and symbols into the map.

title "demofile.sas"; data demofile; input text $char32. function $char8. color $char8. style $char8. xsys $1. ysys $1. hsys $1. position $1. size 1. x 8.4 y 8.4; cards; Everett LABEL ORANGE SWISSL 22431 -.3085 .2300 DOT SYMBOL ORANGE NONE 22451 -.3085 .2300 proc print; run;

This is an interactive method to get the annotate file:

/%let mark=cities.sas; GOPTIONS RESET=ALL DEVICE=WIN CBACK=WHITE CTEXT=BLACK; GOPTIONS KEYMAP=WINANSI DEVMAP=WINANSI; %LET ANNO=demofile; /* Demofile used if no City is specified in the Window 'City' */ TITLE1 C=BLACK F=SWISSL H=5 PCT 'Drawing of Cities into Maps'; footnote c=black f=simplex h=.8 j=r "&mark ";

/* Create the annotate file */ DATA; LENGTH DEFAULT=4; LENGTH TEXT $32 FUNCTION COLOR STYLE $8; RETAIN COLOR ('ORANGE'); RETAIN XSYS YSYS HSYS ('2' '2' '4'); RETAIN SIZE (1); WINDOW CITY COLOR=GREEN COLUMNS=80 ROWS=10 'Drawing of Cities into Maps' C=BLACK A=UNDERLINE // 'Cityname= ' C=BLACK TEXT $CHAR32. C=YELLOW A=REV_VIDEO AUTO=YES / 'X = ' C=BLACK X 6.2 C=YELLOW A=REV_VIDEO AUTO=YES +3 '(cartesian coordinate of longitude used by SAS as X)' / 'Y = ' C=BLACK Y 6.2 C=YELLOW A=REV_VIDEO AUTO=YES +3 '(cartesian coordinate of latitude used by SAS as Y)'; DO UNTIL (_MSG_ = ''); DISPLAY CITY BLANK; IF TEXT='' THEN STOP; IF X < &XMIN | X > &XMAX THEN _MSG_="&XMIN < X < &XMAX"; IF Y < &YMIN | Y > &YMAX THEN _MSG_="&YMIN < X < &YMAX"; END; IF TEXT='' THEN STOP; CALL SYMPUT('ANNO','_LAST_'); FUNCTION='LABEL'; POSITION='3'; STYLE='SWISSL'; OUTPUT; FUNCTION='SYMBOL'; POSITION='5'; STYLE='NONE'; TEXT='DOT'; OUTPUT; RUN;

/* Show the result */ PATTERN V=E C=BLACK R=999; PROC GMAP MAP =MAPS.USCOUNTY (WHERE=(STATE=53)) /* Washington state only */ DATA=MAPS.USCOUNTY (WHERE=(STATE=53)) ANNO=&ANNO; ID COUNTY; CHORO COUNTY / DISCRETE NOLEGEND COUTLINE=BLACK; RUN; QUIT;

By the way only to remember: To stop processing the window CITY you can issue an END command or close the window by mouse.

I think of course my suggestion will not meet your intension completely. But the advantages are 1. you can use it for any SAS map with low level adaptions 2. it works Feel free to modify and adapt my programs and feel free to mail again if there are any questions, please. Hope I could help and good luck to you ...

> I would like to display city names &/or locations on a map of Washington >state.Is there software compatible with SAS graph that would allow me to >display this information? The file us.cities only has coordinates for major >cities. > >Wendy >-- >------------------------------------------------------------------------- >Wendy Harrison (206) 526-2261 >Children's Hospital & Med. Center wendyhar@u.washington.edu >Audiology Research > Mit freundlichen Gruessen

Ihr Wolf F. Lesener

Humboldt-Universitaet zu Berlin - Rechenzentrum - Unter den Linden 6 10099 Berlin Tel. (030) 2093 2464 Fax. (030) 2093 2959

+---------------------------------------------------------------------+ | 2. KSFE in Jena 26.-27. Februar 1998 | | -> KSFE = Konferenz fuer SAS-Anwender in Forschung und Entwicklung | | Bitte beachten Sie die Informationen im Internet unter: | | http://www.uni-jena.de/~ank/ksfe2.html | +---------------------------------------------------------------------+


Back to: Top of message | Previous page | Main SAS-L page