f



Re: Lookup Table in SAS #2

On Fri, 29 Aug 2008 20:42:06 -0400, Nat Wooding <Nathaniel.Wooding@DOM.COM>
wrote:

>Jerry
>
>There are a couple ways to do this in SAS. One is to create a "user defined
>format" and use a put statement to create a new variable based on the value
>of an existing variable and the format that you created. See the SAS
>documentation on Proc Format and the Put function. Note that the values
>that are used in building this format may be manually typed or may be read
>from a SAS data set.
>
>A second way is to merge the two tables and, based on whether there are
>matches between the two tables, the flag may be set with program
>statements. The following illustrates this approach.
>
>Data a;
>input values $1. ;
>cards;
>a
>b
>c
>d
>e
>;
>
>
>Data b;
>informat data2 $10.;
>
>input values   $1.    data1         data2  ;
>cards;
>b            1               something
>x            2               random
>k            3               new
>proc sort;
>      by values;* this solution requires that the two data sets be sorted.
>The format solution does not require sorting;
>run;
>
>Data final;
>    merge b (in = in1 ) a (in=in2);
>      by values;
>      if in1;* select only datalines that exist in b;
>      if in2 then flag = 1;
>           else flag = 0;* see sas data set options discussion;
>proc print;
>run;
>
>Nat Wooding
>Environmental Specialist III
>Dominion, Environmental Biology
>4111 Castlewood Rd
>Richmond, VA 23234
>Phone:804-271-5313, Fax: 804-271-2977

Another way:

   proc sql;
   create table c as
    select *, values in (select values from a) as flag
     from b;
   quit;

>
>
>
>             Jerry Yang
>             <jerryang@CISCO.C
>             OM>                                                        To
>             Sent by: "SAS(r)          SAS-L@LISTSERV.UGA.EDU
>             Discussion"                                                cc
>             <SAS-L@LISTSERV.U
>             GA.EDU>                                               Subject
>                                       Lookup Table in SAS
>
>             08/29/2008 07:09
>             PM
>
>
>             Please respond to
>                Jerry Yang
>             <jerryang@CISCO.C
>                    OM>
>
>
>
>
>
>
>Hello,
>
>Suppose I have dataset called "Lookup_SAS" that has the following values
>with 1 variable called values
>
>values
>--------
>a
>b
>c
>d
>e
>
>
>I have another dataset with multiple variables with another column called
>values also called "data1"
>
>values      data1         data 2
>---------------------------------
>b            1               something
>x            2               random
>k            3               new
>
>
>How do I create a new dataset that compares my first dataset with the
>second
>to product a flag with the following results:
>
>values      data1         data 2             flag
>-----------------------------------------------------------------
>b            1               something         1
>x            2               random            0
>k            3               new               0
>
>
>
>So my question is, how do I create a new variable called flag that contains
>any values within "Lookup SAS" into "data1" within a dataset? flag will
>only
>give a 1 if the value within data1 is contained also in Lookup SAS
>
>Any ideas would be appreciated.
>
>
>Thanks,
>-Jerry
0
hs
8/30/2008 1:07:15 PM
comp.soft-sys.sas 142828 articles. 3 followers. Post Follow

0 Replies
685 Views

Similar Articles

[PageSpeed] 4

Reply:

Similar Artilces:

Re: suggest: improve SAS Deployment Wizard for SAS v9.2, phase 2 #2
> From: A Little Birdie > > I just searched the SAS-L archives (should have done that > first) and found references to these two pages: > > http://www.sascommunity.org/wiki/Category:V9.2_Phase_2 > > http://www.sascommunity.org/wiki/V9.2_Phase_2_install_guide > > Have you seen this page? > ***************************************************** > http://support.sas.com/kb/35/631.html <---<<< NICE! ***************************************************** > It looks like it addresses your needs, and might be something > nice to add to the SASCo...

Re: R vs. SAS (was Replacement for SAS (SPSS vs. SAS, redux)) #2
Sounds like R is the SAS equivalent of Linux .. who are incidentally in all sorts of a copy left/right mess at the moment. On Thu, 5 Feb 2004 09:39:37 -0500, Peter Flom <flom@NDRI.ORG> wrote: >I use both SAS and R; I"ve used SAS for 10 or 15 years, R for about 6 >months - 1 year. > >Each has strengths and weaknesses; I'd not like to give up either. > >Strengths of SAS (esp. compared to R) > >Tech support - I have SAS tech support's phone number and our license >number memorized. They're great. > >SAS-L - There's also an R-help list...

Re: SAS Sample 1728 Was ---> Re: SAS Sample 1727 #2
Graham , I am not sure that the SI Tech Support examples should have all the error checking that Chang wanted to throw in the macro. The examples should be clear concise and easy to read and get going, as well as be illistrative. Too much error checking in an example well is just over kill and even detrimental to an example. However, any code solution on the SI Tech Support web sit should follow basic rules of good practices and sound advice. Such as with thier macros having atleast a somewhat good Macro design. Look at Example SAS Sample 1728: The first method well lets say is soooo bad...

Re: suggest: improve SAS Deployment Wizard for SAS v9.2, phase 2
Subject: Re: v9.2 phase 2, page update "Make the installation of SAS BI Server easier!" .... Ok w/me! Just remember that the majority of us are still just installing only SAS Foundation v9.2, and possibly Enterprise Guide v4.2 My rant/suggestion to Tech Support has been addressed. I have added notes about my conversation with Tech Support to this sas community wiki page: http://www.sascommunity.org/wiki/V9.2_Phase_2_install_guide summary: if you have Build # greater than or equal to 28 then you can dispense with ForceInstall. Ronald J. Fehd, IT Spec HelpDesk Level 3: SAS CDC S...

Re: Running SAS jobs sequentially in batch mode
> Note that unless you clean up work datasets and any macro variables created by each production job, subsequent jobs will not be starting in a pristine environment. It may be a good idea to include a new program between each production job to kill all work datasets and query sashelp.vmacro to create %symdel statements to delete macro variables. Would you be kind enough to give sample statements to do the CLEANING and KILLING? Susie Li TV Guide 1211 Avenue of the Americas New York, NY 10036 Tel 212.852.7453 Email susie.li@tvguide.com -----Original Message----- From: SAS(r) Discussion [m...

Re: SAS/DMS library default library allocations using SAS V8.2 on #2
The library allocations have to be stored <somewhere>, otherwise you wouldn't continue to get the prompt. You can look under your userid to see if it's there (though I suspect you've already done that), but a better question would be directed at the SAS sysadmin--ask them where these profiles/customizations are stored (the sasuser.profile is the generic one--your personal one is concatenated along with it). You may be able to see your session info under your userid tso log (shows usage information), though off the top of my head I can't remember if it captures al...

Re: Lookup Table in SAS
Jerry There are a couple ways to do this in SAS. One is to create a "user defined format" and use a put statement to create a new variable based on the value of an existing variable and the format that you created. See the SAS documentation on Proc Format and the Put function. Note that the values that are used in building this format may be manually typed or may be read from a SAS data set. A second way is to merge the two tables and, based on whether there are matches between the two tables, the flag may be set with program statements. The following illustrates this approach. Data a; input values $1. ; cards; a b c d e ; Data b; informat data2 $10.; input values $1. data1 data2 ; cards; b 1 something x 2 random k 3 new proc sort; by values;* this solution requires that the two data sets be sorted. The format solution does not require sorting; run; Data final; merge b (in = in1 ) a (in=in2); by values; if in1;* select only datalines that exist in b; if in2 then flag = 1; else flag = 0;* see sas data set options discussion; proc print; run; Nat Wooding Environmental Specialist III Dominion, Environmental Biology 4111 Castlewood Rd Richmond, VA 23234 Phone:804-271-5313, Fax: 804-271-2977 Jerry Yang <jerryang@CISCO.C OM> To ...

Re: Autoexec.sas file Dm"pgm;zoom;"; doesnot wrk in SAS 9.2 #2
Hi Ace, The PGM is the editor window up through v6.12 but also still exists today. For the Enhanced Editor you can use: dm editor 'zoom' wedit ; Hope this is helpful. Mark Terjeson Investment Business Intelligence Investment Management & Research Russell Investments 253-439-2367 Russell Global Leaders in Multi-Manager Investing -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Ace Sent: Wednesday, October 14, 2009 5:49 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Autoexec.sas file Dm"pgm;zoom;"; doesnot wrk in SAS...

Re: SAS 8.2 = SAS 8.02 ?
On Mon, 6 Dec 2004 10:29:57 -0500, Igor Kurbeko <ikurbeko@ATHEROGENICS.COM> wrote: >Hi, guys. > > > >Are SAS releases 8.2 and 8.02 one and the same? > > > >I wanted to apply hot fix for SAS Release 8.2 (TS2M0) B2BB97. > >But we use SAS 8.02 Hi, Igor, SAS releases 8.2, 8.02, and 8e refer to the same thing Release 8.2 (TS2M0), at least on Windows platform and likely so in other platforms. It seems an outcome of the development and marketing not in sync -- which is much frequent happening in the industry. Like Java 2 is in fact Java 1.2 and above, ms off...

Re: Difference Between PC SAS and UNIX SAS #2
I cannot give a complete list by any means for these two systems but there are functions listed in TS486 that are specific to windows and afaik, Sleep is one of these. I suggest that you look at the Companion to the ... Operating System in the online docs for each of these and compare the two systems. Nat Wooding Environmental Specialist III Dominion, Environmental Biology 4111 Castlewood Rd Richmond, VA 23234 Phone:804-271-5313, Fax: 804-271-2977 Suthakar Iyer <suthakariyer@YAH OO.COM> To Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU Discussion" cc <SAS-L@LISTSERV.U GA.EDU> Subject Difference Between PC SAS and UNIX SAS 06/05/2008 02:28 PM Please respond to suthakariyer@yaho o.com Hi, Whether there is any difference between PC SAS and UNIX SAS &nbsp;from the functionality or user point of view. &nbsp; If there is a difference , kindly can you mention it. &nbsp; Thanks for the help in advance. &nbsp; Suthakar &nbsp; &nbsp; ----------------------------------------- CONFIDENTIALITY NOTICE: This electronic message contains information w...

Re: Deleting SAS Data from a SAS DATASET #2
Chandra - this isn't my expertise area - I'm sure others may have better ideas but I'll make three comments. If your datasets have a large number of variables, in your datastep method a WHERE clause will be more efficient - the IF statement causes each record to be fully read before it can be selected for deletion. A WHERE clause would only read the single variable in the case of records that meet the criteria for deletion. Data prod.Master_date; set prod.master_date; where snap_dt ne "&end_dt"d; run; You probably would be better off changing your data model though - my first thought would to be to store your data as separate yearly or monthly files and then access them with a view of the past two years or 24 months. With each month or year you would delete the oldest file and change the view one time period forward. *set up the data; data time1 time2 time3 time4; do i = 1 to 100; do t = 1 to 4; if t=1 then output time1; if t=2 then output time2; if t=3 then output time3; if t=4 then output time4; end; end; run; *three successive example views; data filet1 / view=filet1; set time1 time2; run; data filet2 / view=filet2; set time2 time3; run; data filet3 / view=filet3; set time3 time4; run; One more thought - since the data are appended - if the file is not reordered and you have the record counts from each append - then you can use firsto...

Re: EWMA in base SAS / or SAS/STAT? #2
>From: Michael Murff <mysasbox@GMAIL.COM> >Reply-To: Michael Murff <mysasbox@GMAIL.COM> >To: SAS-L@LISTSERV.UGA.EDU >Subject: EWMA in base SAS / or SAS/STAT? >Date: Wed, 11 Oct 2006 18:57:15 -0600 > >Hi, > >I'm wondering if others are aware of open source coding for Exponentially >Weighted Moving Average (EWMA) or other advanced time series smoothers (eg. >holt winters) in base SAS? Just putting out a feeler in the hope that I >don't have to reinvent the wheel :-) > >TIA, > >M.M. I'm guessing you're still in that SQC ...

Re: Is it possible to read a sas dataset NOT using sas? #2
I think SPSS and DBMSCopy can read SAS datasets. Also for sure WPS. Gerhard On Tue, 18 Mar 2008 06:43:44 -0700, RolandRB <rolandberry@HOTMAIL.COM> wrote: >Is it possible to read a sas dataset NOT using sas and have >observations and variables etc. rather than having meaningless chunks >of text? ...

Re: SAS vs. SPLUS vs. SAS #2 1617385
Hi Paul have not used S-Plus since around 2000-2002 so this may be Old News from S-Plus conference attendance they know their strength is: * rapid prototyping * great graphics downside: * you want speed! load all data into memory! column-wise operations * need to upgrade hardware w/more memory for large data sets * check documentation to find BigData functions which, iirc, operate like SAS does: row-wise previous version: v7 current version: v8.1 *** SAS: SAS/IML now has IML/Studio which enables access to R programs R is the open-source version of S+ ...

Re: SAS-Related Friday Gift For All SAS-Lers #2
One more tip about the Book: *Seafood, Pictures, Facts, and Nutrition Information; you don't have to download the whole book to browse its pages. Just point your Browser at: www.warpraptor.com and navigate to ** AtlantaFishMarketBookTable_Of_Contents.pdf. Open this document and use the Table of Contents found there (starting on page 3) to access all the sections by clicking the individual Table of Contents items. If you choose the COMPARATIVE SPECIES NUTRITION SUMMARIES item, the legend for the nutrition data graphics will be found on page two of this same document.* ** *On Fri, Jul 24...

Re: urgent : Convert SAS array in to sas variables #2
On Sat, 3 May 2008 23:34:44 -0700, Shailesh <shailesh.tewari@GMAIL.COM> wrote: >In my dataset I have an array variable , say A which has values like >Observation 1 - A[1]= 23 ,A[2]=34, A[3]=45 >Observation 2 - A[11]= 23 ,A[12]=34, A[13]=45 > >I want to create sas variables which should have name A61, A62 , A63, >A64 .......... >Similarly for second observation these would be A71, A72, >A73 , A74......... > > >in the same datastep. > >Any help ? > >Regards, >Shailesh Arrays are DATA *step* structures. They do not exists in data *...

Re: SAS Macro to delete a SAS dataset #2 313487
I too like(d) PROC DELETE. When I used it I was forced to remove it and use PROC DATASETS because PROC DELETE is not documented. Also, but I have not tested it. How does it work with indexed data sets, audit trails, generation data groups, views, etc.? I don't worry much about deleting, "all" of my programs run in batch and are obsolete as soon as they are written. On 12/3/09, Fehd, Ronald J. (CDC/CCHIS/NCPHI) <rjf2@cdc.gov> wrote: > > From: SAS Techies > > Subject: SAS Macro to delete a SAS dataset > > > > Here's a simple SAS...

Re: Lookup Table in SAS #4
hi ... and one more idea ... given data sets a and b data a; input values : $1. @@; datalines; a b c d e ; run; data b; input values : $1. data1 data2 : $ 10.; datalines; b 1 something x 2 random k 3 new ; run; * a tweak of Patrick's hash solution; data c; declare hash h(dataset: 'a'); h.defineKey('values'); h.defineDone(); do until (lastb); set b end=lastb; flag = (h.find() eq 0); output; end; stop; run; -- Mike Zdeb U@Albany School of Public Health One University Place Rensselaer, New York 12144-3456 P/518-402-6479 F/630-604-1475 > Hello, > > Suppose I have dataset called "Lookup_SAS" that has the following values > with 1 variable called values > > values > -------- > a > b > c > d > e > > > I have another dataset with multiple variables with another column called > values also called "data1" > > values data1 data 2 > --------------------------------- > b 1 something > x 2 random > k 3 new > > > How do I create a new dataset that compares my first dataset with the second > to product a flag with the following results: > > values data1 data 2 flag > ----------------------------------------------------------------- > b 1 somet...

Re: SAS Table help #2
Monti, Either Ian, I, or both of us have misunderstood what you might be looking for. If your data show the number of missing data elements, by product type, then I think you want something like the following: data have; input Product $ ItemA ItemB ItemC ItemD ItemF; cards; A 1 . 2 9 . B 2 2 0 3 9 C 6 5 9 . 8 D 5 . 5 7 8 E 5 . 2 8 . F . 2 3 6 7 G . 8 2 . 5 H 5 . . 8 1 ; data temp; set have ; nmiss = sum (of item: ) ; run; proc sql; create table want as select product,nmiss,100*nmiss/sum(nmiss) as pct_of_total from temp; quit; HTH, Art --------- On Mon, 2 Feb 2009 13:14:41 -0800, Mahbub Khandoker <mk_sas1@YAHOO.CA> wrote: >Hi there, >I am very new to SAS. I want to create a table from SAS database which includes statistics for all the missing data elements by product type. >The database looks like as follows, >� >Product����������� ItemA�� ItemB ItemC ItemD ItemF >A�������������������� 1��������� ����������� 2��������� 9��������� >B��������������������� 2��������� 2��������� 0��������� 3��������� 9 >C�������������������� 6��������� 5��������� ����������� 9.�������� 8 >D�������������������� 5��������� ����������� 5��������� 7��������� 8 >E��������������������� 5��������� ����������� 2��������� 8��������� >F��������������������� ����������� 2��������� 3�...

Re: old SAS guy with new SAS question #2
On Sun, 16 Nov 2008 21:18:36 -0600, John F. Regus <jfregus@IX.NETCOM.COM> wrote: >You three were of the most help to an old man in simplifying how to get output from my PC file into a SAS dataset. However, when I did use the INPUT statement I coded INPUT $. thinking this would put everything into its natural place in the output SAS table. Wrong. It only got the first variable of 5 characters. > >I went through my "Little SAS Book" trying to find the answer to this but the "Little SAS Book" has an appropriate title...it is little and does not cover a lot of things. SAS help and documentation takes you over the hills and through the woods without getting to the point or even a concise answer. > >Here is my problem. > >I am reading a .csv PC flat file (I conquered the problem of reading the PC file into a SAS dataset by adding the INPUT statement...only not all the data goes through because I need to use columnar input instead of list input). > >The layout of the .csv PC flat file is somewhat like this, with the variable lengths inside each table entry looks something like this: > > VAR1 VAR2 VAR3 VAR4 VAR5 etc.,etc. > >Row1 5$ 1$ 1$ 8$ 6$ > >Row2 5$ 2$ 1$ 18$ 6$ > >Row3 5$ 4$ 1$ 10$ 6$ > >Row4 5$ 4$ 1$ 6$ ...

Re: Lookup Table in SAS #3
hi ... in the true spirit of "beating a question to death" ... here are a couple more to add to those already posted (though Howard Schreier's SQL solution is so elegant that I wonder why one would do anything different) ... given data sets a and b data a; input values : $1. @@; datalines; a b c d e ; run; data b; input values : $1. data1 data2 : $ 10.; datalines; b 1 something x 2 random k 3 new ; run; * add an index to data set a; proc datasets lib=work nolist; modify a; index create values; quit; data c; set b; set a key=values/unique; flag = not (_error_); * add the next statement if you don't like RC messages in the LOG; _error_= 0; run; * create a lookup string from data set a; data c; length ina $50; do until(lasta); set a end=lasta; ina = catt(ina,values); end; do until(lastb); set b end=lastb; flag = (find(ina,values) gt 0); output; end; drop ina; run; * a tweak of Nat Wooding's MERGE solution (get rid of IF) ... assumes sorted data sets; data c; merge a (in=ina) b (in=inb); by values; flag = ina; if inb; run; -- Mike Zdeb U@Albany School of Public Health One University Place Rensselaer, New York 12144-3456 P/518-402-6479 F/630-604-1475 > Hello, > > Suppose I have dataset called "Lookup_SAS" that has the following values > with 1 variable called values > > values > -------- > a > b > c > d > e > > > I ha...

Re: search SAS data set from SAS code #2
Rose, The answer to your question depends on your operating system. In Windows, there's the Search tool. In Unix/Linux, you can use grep Bob Abelson HGSI 240 314 4400 x1374 bob_abelson@hgsi.com Rose <myr_rose@YAHOO.COM> Sent by: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> 04/19/2005 11:13 AM Please respond to myr_rose To: SAS-L@LISTSERV.UGA.EDU cc: Subject: search SAS data set from SAS code Hi All, Suppose I have a sas permanent data set which was created early, I know the library path but I couldn't remember in which s...

Re: SAS 9.2 Phase 2 #2
That is correct -- Phase 2 updates the "Foundation" products (Base SAS, SAS= /GRAPH, etc.), and also I believe is the first release for BI and some othe= r server-based products like that. (We don't license these, so I haven't lo= oked into this in detail.) My understanding is also that the "foundation" p= roducts must be completely reinstalled going from Phase 1 to Phase 2. If your bug is in the Problem Notes, you might be able to check there to se= e whether it is corrected in Phase 2. Mike Rhoads RhoadsM1@Westat.com -----Original Message----- From: D T [mailto:sasandstats@live.com] Sent: Thursday, March 26, 2009 9:33 AM To: Mike Rhoads; sas-l@listserv.uga.edu Subject: RE: [SAS-L] SAS 9.2 Phase 2 Is SAS 9.2 phase 2 the update to the first version of 9.2? I am waiting for= the update since there is supposed to be a correction to a bug within the = survey procedures ... can you confirm this? Also, if that's correct, how do= you get it? I couldn't find an announcement on the SAS website ... Thanks! D. > Date: Thu, 26 Mar 2009 08:23:27 -0400 > From: RHOADSM1@WESTAT.COM > Subject: Re: [SAS-L] SAS 9.2 Phase 2 > To: SAS-L@LISTSERV.UGA.EDU > > It is now shipping, at least in the U.S. as of last week, or so I've been= told from reliable sources. (I'm a little surprised they didn't make a big= ger deal of it at the conference.) > > I don't know about abroad. I've heard that new releases can be...

Re: LOCAL SAS USER GROUPS
On Fri, 22 Dec 2006 08:02:28 -0500, Charles Patridge <charles_s_patridge@PRODIGY.NET> wrote: >TO All Local SAS User Groups, > >HASUG is again in a pickle to find a good / cheap method to send out >emails to its local members. HASUG would like to know what email services >each of you use to keep in contact with your members. > >Some of HASUG's requirements for such a list are: >1. Must be confidential >2. Must not be shared with anyone, any company, etc >3. Self maintained with regards to bad email addresses, obsolete email >addresses >4. Allo...

Web resources about - Re: Lookup Table in SAS #2 - comp.soft-sys.sas

Lookup A Cell Phone Number Dot Com
Lookup cell phone numbers by name or reverse lookup cell phone number to find name and address.

DNS Lookup - Everything to do with DNS, DDNS, and Free Services
December 23, 2011 admin DDNS , Dynamic Dns , 0 There are about a billion dynamic dns vanity hostnames available, so it is a very difficult exercise ...

Pet Microchip Lookup - Powered by AAHA
Instructions: Enter the microchip ID above and click "Submit". Enter only the 9, 10 or 15 character microchip number, with no punctuation or ...

Publishers List - Welcome to Publisher Lookup UK.
Many people find it difficult to access the world of books. Whether through dyslexia, visual impairment or motor difficulties, thousands of ‘would ...

Lookup table - Wikipedia, the free encyclopedia
In computer science , a lookup table is an array that replaces runtime computation with a simpler array indexing operation. The savings in terms ...

Voter Lookup
Mail to: Tarrant County Elections office, 2700 Premier St., Ft. Worth, Tx 76111 or fax to 817-831-6475, Attn: Web Opt-out.

Cell Phone Lookup Emporium - Home
Cell Phone Lookup Emporium Home Free Cell Phone Lookup Resource Connections We have spent some considerable time identifying websites with valuable ...

DNS Lookup
Without DNS (domain name system) we would not be able to use our favourite websites such as Facebook and Twitter, nor would we be able to check ...

Facebook Adds 25 New Preferred Developer Consultants, Improves PDC Lookup Tool
... number of developers in the PDC Directory to 90. It also added expertise filters to a newly launched version of the Preferred Developer Lookup ...

Search Twitter - LOOKUP
Sign in Sign up Search Refresh emyri d. @ LookUP_itsMoine 24m love and hip hop tonight 😁 View details · Martin Miles @ martincmiles 34m This ...

Resources last updated: 3/16/2016 8:32:09 PM