Date: Thu, 23 Aug 2007 11:52:15 -0700
Reply-To: Brandon_Thinkpad <brandonpen@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Brandon_Thinkpad <brandonpen@GMAIL.COM>
Organization: http://groups.google.com
Subject: Re: Access a specific observation?
In-Reply-To: <1187892364.214487.149970@r23g2000prd.googlegroups.com>
Content-Type: text/plain; charset="us-ascii"
Paul, your tip worked perfectly; thank you sir!
On Aug 23, 2:06 pm, Brandon_Thinkpad <brandon...@gmail.com> wrote:
> To try to explain better, here is the pseudo-code for what I want to
> happen:
>
> if find (AcroMerged{1}, CC{x}, 't') then StringFoundCC='XTRUE';
> if find (AcroMerged{1}, UID{x}, 't') then StringFoundUID='XTRUE'
> if not find(AcroMerged{1}, CC{x}, 't') then StringFoundCC='FALSE';
> if not find(AcroMerged{1}, CC{x}, 't') then StringFoundUID='FALSE';
>
> variable X would be on a counter to move to the next observation to
> check against the first value of variable AcroMerged, and it's array
> index 1.
>
> Please bare with me, I am thinking in terms of VisualBasic in my usage
> of the arrays --- I understand that arrays in SAS actually stores
> OBSERVATIONS as opposed to actual values.
>
> On Aug 23, 1:58 pm, Brandon_Thinkpad <brandon...@gmail.com> wrote:
>
> > This reply was very helpful!
>
> > My task is to compare observations in two columns of a dataset,
> > against the value of a variable. More specifically, it is to search
> > for columns CC and UID against a variable string AcroMerged.
>
> > if find (AcroMerged, CC, 't') then StringFoundCC='XTRUE';
> > if find (AcroMerged, UID, 't') then StringFoundUID='XTRUE';
> > if not find(AcroMerged, UID, 't') then StringFoundCC='FALSE';
> > if not find (AcroMerged, UID, 't') then StringFoundUID='FALSE';
>
> > The problem is that I want to compare every value of CC and UID (from
> > the first dataset) against the FIRST LINE of AcroMerged (in a second
> > dataset), and then the SECOND LINE of AcroMerged, and then the THIRD
> > line of AcroMerged, and then the FOURTH LINE of AcroMerged, etc.
> > until the end of the second dataset. I had some code that semi-works,
> > however it seems like it compares each instance of the observations
> > against the corresponding observation in the second data set. Whereas
> > the first dataset could potentially be hundreds of thousands of lines
> > long, the second data set is only a few hundred lines long. It
> > stopped searching at the end of the second data set.
>
> > I figured I could do the comparisons using an array technique and a
> > counter.
>
> > On Aug 23, 12:41 pm, nos...@HOWLES.COM ("Howard Schreier <hs AT dc-sug
>
> > DOT org>") wrote:
> > > On Thu, 23 Aug 2007 15:54:30 +0000, toby dunn <tobyd...@HOTMAIL.COM> wrote:
> > > >Data Test ;
> > > >Infile Cards ;
> > > >Input Text $ ;
> > > >If _N_ In ( 1 3 ) ;
> > > >Cards ;
> > > >Hello
> > > >Goodbye
> > > >NoDeal
> > > >;
> > > >Run ;
>
> > > >Proc Print
> > > >Data = Test ;
> > > >Run ;
>
> > > >Toby Dunn
>
> > > >From: Brandon_Thinkpad <brandon...@GMAIL.COM>
> > > >Reply-To: Brandon_Thinkpad <brandon...@GMAIL.COM>
> > > >To: SA...@LISTSERV.UGA.EDU
> > > >Subject: Access a specific observation?
> > > >Date: Thu, 23 Aug 2007 08:49:10 -0700
>
> > > >I am relatively new to the world of SAS, and I would like to know
> > > >specifically how to read a specific observation --- I was hoping that
> > > >this worked similarly to reading a specific array index, but it
> > > >doesn't appear to be the case.
>
> > > >For example, I submit the following pseudo-code :
> > > >-------------------------------
> > > >data TESTINGARRAYS;
> > > >file = 'c:\specific-observation-output.txt';
>
> > > >input testing;
>
> > > >put testing(OBSEVATION # 1);
> > > >put testing (OBSERVATION # 3);
>
> > > >datalines;
> > > >Hello
> > > >Goodbye
> > > >NoDeal
> > > >;
> > > >------------------------------
>
> > > >I am having trouble working with specific observation numbers in
> > > >general; any assistance would be appreciated! BTW, the desired output
> > > >for the above program would be to output "Hello" and "NoDeal" to the
> > > >file specific-observation-output.txt, while omitting the second
> > > >observation "Goodbye".
>
> > > You can do this once your data reside in a SAS data set. Adapting Toby's
> > > example:
>
> > > Data Test ;
> > > Infile Cards ;
> > > Input Text $ ;
> > > Cards ;
> > > Hello
> > > Goodbye
> > > NoDeal
> > > ;
>
> > > data _null_;
> > > do wanted_obs = 1, 3;
> > > set test point=wanted_obs;
> > > put text;
> > > end;
> > > stop;
> > > run;
>
> > > However, this is not a mainstream way of doing things in SAS. Perhaps if we
> > > know the actual task we can make other suggestions.
|