Date: Thu, 23 Aug 2007 10:58:37 -0700
Reply-To: Brandon_Thinkpad <brandonpen@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Brandon_Thinkpad <brandonpen@GMAIL.COM>
Subject: Re: Access a specific observation?
Content-Type: text/plain; charset="us-ascii"
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
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 ;
> >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);
> >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
> Data Test ;
> Infile Cards ;
> Input Text $ ;
> Cards ;
> data _null_;
> do wanted_obs = 1, 3;
> set test point=wanted_obs;
> put text;
> However, this is not a mainstream way of doing things in SAS. Perhaps if we
> know the actual task we can make other suggestions.