| Date: | Wed, 26 Nov 2003 13:53:12 -0500 |
| Reply-To: | Patrice.Bourdages@IAAH.CA |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Patrice Bourdages <Patrice.Bourdages@IAAH.CA> |
| Subject: | Re: Vlookup feature in SAS? |
|
| Content-Type: | text/plain; charset="iso-8859-1" |
Consider the following :
TableA
Agent Year Obj
3211 2003 13
3211 2004 16
etc.
TableB
{your actual dataset as listed below}
ResultingTable
Agent Year Obj X Y
3211 2003 13 0.03 0.0375
3211 2004 16 0.00 0.02
etc.
I would do it this way :
Data work.ResultingTable;
Set TableA;
ERRPREL = _ERROR_;
** Open up the "Lookup Table" and look for Year from TableA **;
set work.TableB key=Year /unique;
if _IORC_ = %sysrc(_DSENOM) and ERRPREL = 0 then _ERROR_ = 0;
** If no match found in TableB, do something about it **;
if _IORC_ ne 0 then do;
error_TableB = 1;
** Store a missing value to X and Y since the were no "lookup value"
available **;
x = .;
y = .;
end;
** Drop this variable as it is not needed anymore. **;
drop errprel;
run;
Don't forget to "Index" your table "TableB" so that the lookup will be as
fast as lightning...
Hope this helps you a little bit.
Patrice Bourdages
Direction des technologies
Poste: 3216
-----Message d'origine-----
De : Todd A Goselin [mailto:tgoselin@YAHOO.COM]
Envoyé : 26 novembre, 2003 13:31
À : SAS-L@LISTSERV.UGA.EDU
Objet : Vlookup feature in SAS?
Hello,
I have a dataset that looks like:
2003 0.03 0.0375
2004 0.00 0.02
2005 0.00 0.02
2006 0.00 0.02
2007 0.00 0.02
2008 0.00 0.02
2009 0.00 0.02
2010 0.00 0.02
2011 0.00 0.02
2012 0.00 0.02
2013 0.00 0.02;
All I want to do is use something like the Microsoft Excell Vlookup function
that uses a keyword (in this case a Year, and get the next columns data.
Does anyone have an idea what to do? It looks like SAS does not have a
vlookup feature.
My goal is to have something scan the table above and get the second column
for a specific year.
Thanks,
Todd
---------------------------------
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
|