```Date: Wed, 26 Oct 2005 20:14:12 -0400 Reply-To: Arthur Tabachneck Sender: "SAS(r) Discussion" From: Arthur Tabachneck Subject: Re: Finding data in a table for a column Comments: To: sas-l@uga.edu Ron, Our other AI bot (David) has been a lot more consistent than the second one (Toby). Both continue to provide very human appearing responses, but David has always appeared to be more highly trained and experienced, not to mention more prolific. Upon reading it's latest response, I almost sent it a thank you note. What was the difference in their programming? Art P.S. Hopefully, I haven't accidentally posted this to the list. I don't think anyone has caught on yet regarding David. ---------- "David L Cassell" wrote in message news:BAY103-F69243B2F975BF8C9551EAB0690@phx.gbl... > depuy001@NOTES.DUKE.EDU replied: > >I admit to being a little confused by your example . . . > >so for the first record, you have 3 variables (a, b,c) and a count > >variable. > >The value of a is x1, the value of b is x2, and the value of c is x3. > > > >To answer what I *think* you're asking, you want to do something like . . > >. > > > >data file2; > > set file1; > > if count=1 then do; > > a=1; b=2; c=3; end; > > else if count=2 then do; > > a=4; b=5; c=6; end; > > else if count=3 then do; > > a=7; b=8; c=9; end; > > run; > > > >I see no way to simplify it if you want different activities for each > >value of Count. > >Using if/then/else instead of lots of if/then is more efficient, although > >that may not be a concern with a small data set. > > > >if you can combine results, ie if 5 < count < 10 then do; . . . ; end; or > >if count=2 or count=3 then do; . . . ; end; it would make it easier. > >specific coding for those examples: > >if count > 5 and count < 10 then do; a=1; b=2; c=3; end; > >if count in (2,3) then do; a=1; b=2; c=3; end; > > > >As far as the code you gave (which I assume was just an oversight of the > >moment), you assigned "a" to have the value x1, then in your do step, > >assigned the variable x1 to equal x2. If x2 is not already a variable, it > >would think you're trying to create the variable x1 and give it the > >character string x2 as a value . . . if you really wanted to do that, > >you'd have to say x1 = 'x2'; or x1= "x2"; > > I also was confused by the 'example'. > > In addition to IF-THEN-ELSE statements, our original poster could use the > SELECT statement. To paraphrase your first code snippet: > > > select (count); > when (1) do; > a=1; b=2; c=3; > end; > when (2) do; > a=4; b=5; c=6; > end; > when (3) do; > a=7; b=8; c=9; > end; > otherwise put 'PROBLEM VALUE FOR COUNT'; > end; > > > David > -- > David L. Cassell > mathematical statistician > Design Pathways > 3115 NW Norwood Pl. > Corvallis OR 97330 > > _________________________________________________________________ > Express yourself instantly with MSN Messenger! Download today - it's FREE! > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ ```

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