LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (May 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 5 May 2009 13:39:50 -0700
Reply-To:     "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Subject:      Re: Referencing data set B in data step A's DO loop
In-Reply-To:  <d686e326-a23b-455b-a3eb-5696a32988a8@b7g2000pre.googlegroups.com>
Content-Type: text/plain; charset=windows-1252

> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of > Andrew Z. > Sent: Tuesday, May 05, 2009 12:23 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Referencing data set B in data step A's DO loop > > How do I reference the data set 'correct_domains' in the do loop, so I > can look for close Levenshtein distances (to find misspelled domains)? > > data correct_domains; > input domain $200.; > infile datalines truncover; > datalines; > yahoo.com > gmail.com > hotmail.com > aol.com > comcast.net > msn.com > sbcglobal.net > verizon.net > bellsouth.net > cox.net > att.net > ;;;; > run; > > data check_these_domains; > input domain $200.; > infile datalines truncover; > datalines; > yahoo.cm > gmail.co > hotmial.com > aol.com > comcast.net > ;;;; > run; > > data checked; > set check_these_domains; > do _i_ = 1 to 11; > r = COMPLEV(???, domain); > if r in (1,2) then leave /* do something useful */; > run; > run; > > > > > > Andrew

Here is one option, there are probably more elegant solutions.

data _null_; if 0 then set correct_domains nobs=nobs; call symput('ndomains', put(nobs,best.)); run;

data checked(drop=_:); **-- read correct domains into an array --**; if _n_ EQ 1 then do _i=1 by 1 until(eof); set correct_domains end=eof; array temp[&ndomains] $200 _temporary_ ; temp[_i] = domain ; end;

set check_these_domains; do _i_ = 1 to &ndomains; r = COMPLEV(temp[_i_], domain); if r in (1,2) then leave /* do something useful */; end; put "done" _i_= r=; /* doing something semi-useful */ run;

Hope this is helpful,

Dan

Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204


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