[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sas-l
Subject:    Re: how to select 100 obs. based on distance between the centers of two zip codes
From:       ethan zhou <e75wez1 () GMAIL ! COM>
Date:       2012-07-31 18:18:04
Message-ID: CAKATOfoVrYXdOAeUtnSXV4eJMCAGsUEQeB5vQ19-xnNrAMawCw () mail ! gmail ! com
[Download RAW message or body]

I don't have any experiences on using Proc KRIGE2D? How do I start here?

Thanks.

Ethan

On Tue, Jul 31, 2012 at 10:05 AM, oloolo <dynamicpanel@yahoo.com> wrote:

> 1. try PROC KRIGE2D  OUTN=; MODEL NP=100
> 2. try PROC MODECLUS
>
>
> On Mon, 30 Jul 2012 14:06:12 -0400, ethan zhou <e75wez1@GMAIL.COM> wrote:
>
> >Mike,
> >I still have a hard time on how to select 100 obs. by using your code for
> >state of Vermont.
> >Those 100 obs. may scatter in the zip code itself or plus first one zip
> >codes, first two zip codes, ... first n zip code. How do I build an
> algorithm
> >to pick them up?
> >
> >Thanks.
> >
> >Ethan
> >
> >
> >On Thu, Jul 26, 2012 at 5:31 PM, ethan zhou <e75wez1@gmail.com> wrote:
> >
> >> Mike,
> >> Thanks again for your helps. I never thought this way to solve the
> problem
> >> so elegantly.
> >>
> >> Ethan.
> >>
> >>
> >>
> >>
> >> On Thu, Jul 26, 2012 at 4:38 PM, Zdeb, Michael S <mzdeb@albany.edu>
> wrote:
> >>
> >>> Hi ... here's one way I have used to find the neighbors for each
> state ...
> >>>
> >>> * use maps.states data set to find neighbors (share x/y coordinates);
> >>> proc sql;
> >>> create view temp as
> >>> select distinct a.state as state, b.state as state0
> >>> from maps.states as a, maps.states as b
> >>> where a.state ne b.state and a.x eq b.x and a.y eq b.y
> >>> order by state, state0;
> >>> quit;
> >>>
> >>> proc transpose data=temp out=neighbors (drop=_:) prefix=state;
> >>> by state;
> >>> run;
> >>>
> >>> * create a format for state numbers to state name;
> >>> data fmt / view=fmt;
> >>> retain fmtname 'sta2nam';
> >>> do start = 1 to 56;
> >>>    label = fipname(start);
> >>>    output;
> >>> end;
> >>> run;
> >>>
> >>> proc format cntlin=fmt;
> >>> run;
> >>>
> >>> * states with neighbors (no Alaska and Hawaii ... no neighbors);
> >>> proc print data=neighbors;
> >>> format state sta2nam.;
> >>> run;
> >>>
> >>>
> >>>
> >>>
> >>> Mike Zdeb<http://www.albany.edu/~msz03/>
> >>> U@Albany School of Public Health
> >>> One University Place (Room 119)
> >>> Rensselaer, New York 12144-3456
> >>> P/518-402-6479 F/630-604-1475
> >>>
> >>> ________________________________
> >>> From: ethan zhou [e75wez1@gmail.com]
> >>> Sent: Thursday, July 26, 2012 10:18 AM
> >>> To: Zdeb, Michael S
> >>> Cc: sas-l@listserv.uga.edu
> >>> Subject: Re: how to select 100 obs. based on distance between the
> centers
> >>> of two zip codes
> >>>
> >>> Mike,
> >>> Thanks for your great helps.
> >>>
> >>> Now I can work on setting up the rules for pre-processing the data you
> >>> pointed out.
> >>>
> >>> The idea is to find all states that share the boundary with any
> >>> particular state.
> >>>
> >>> Ethan
> >>>
> >>>
> >>>  On Wed, Jul 25, 2012 at 2:57 PM, Zdeb, Michael S <mzdeb@albany.edu
> >>> <mailto:mzdeb@albany.edu>> wrote:
> >>> hi ... here's one idea (might take a while with 3,000 zips ... there
> are
> >>> only 309 zips in Vermont so the following is pretty fast)
> >>>
> >>> you could do some pre-processing of your data and add some rules
> >>> for example, if you have data from all over the US, there's no reason
> to
> >>> be computing distances from zips in New York to zips in California
> >>> zips in New York and neighboring states are better candidates for
> closest
> >>> zips
> >>> it wouldn't be that difficult to rules ... but if setting up the rules
> >>> takes longer than the"sledgehammer" approach, use the "sledgehammer"
> >>>
> >>>
> >>> * some zips to work with ... all of Vermont with some duplicate zips
> >>> added;
> >>> data zips (drop=state);
> >>> set sashelp.zipcode (keep=zip state);
> >>> where state eq 50;
> >>> output;
> >>> if ranuni(999) le .2 then output;
> >>> run;
> >>>
> >>> * find distances between zips;
> >>> proc sql;
> >>> create table d1 as
> >>> select distinct a.zip as zip, b.zip as zzip, zipcitydistance
> (a.zip,b.zip)
> >>> as distance
> >>> from zips as a, zips as b
> >>> where a.zip ne b.zip
> >>> order by a.zip, distance;
> >>> quit;
> >>>
> >>> * keep 10 closest zips and distances;
> >>> data d2 (keep=zip z1-z10 d1-d10 index=(zip));
> >>> array z(10);
> >>> array d(10);
> >>> do j=1 by 1 until (last.zip);
> >>>    set d1;
> >>>    by zip;
> >>>    if j le 10 then do;
> >>>       z(j) = zzip;
> >>>       d(j) = distance;
> >>>    end;
> >>> end;
> >>> format zip z1-z10 z5.;
> >>> run;
> >>>
> >>> * combine closest zips/distance with original data set (the one with
> >>> duplicate zips);
> >>> data zips;
> >>> set zips;
> >>> set d2 key=zip / unique;
> >>> run;
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> Mike Zdeb
> >>> U@Albany School of Public Health
> >>> One University Place (Room 119)
> >>> Rensselaer, New York 12144-3456
> >>> P/518-402-6479<tel:518-402-6479> F/630-604-1475<tel:630-604-1475>
> >>>
> >>> ________________________________________
> >>> From: SAS(r) Discussion [SAS-L@LISTSERV.UGA.EDU<mailto:
> >>> SAS-L@LISTSERV.UGA.EDU>] on behalf of Ethan [e75wez1@GMAIL.COM<mailto:
> >>> e75wez1@GMAIL.COM>]
> >>> Sent: Wednesday, July 25, 2012 1:44 PM
> >>> To: SAS-L@LISTSERV.UGA.EDU<mailto:SAS-L@LISTSERV.UGA.EDU>
> >>>  Subject: how to select 100 obs. based on distance between the centers
> >>> of              two zip codes
> >>>
> >>> Hi all,
> >>> I  have a 30,000 obs file with the 5-digit U.S. postal zip code
> variable.
> >>> There are 3,000 distinct zip codes in the file. Hence there is more
> than
> >>> one obs. with same zip code.
> >>> Now for each zip code of 3,000, I wanted to select 100 obs. based on
> the
> >>> shortest distance between the centers of two zip codes.
> >>>
> >>> How do I create a macro to accomplish this?
> >>>
> >>> Many thanks in advance.
> >>>
> >>> Ethan
> >>>
> >>
> >>
>
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic