Date: Fri, 28 Jul 2000 21:27:05 +0100
Reply-To: Peter Crawford <Peter@CRAWFORDSOFTWARE.DEMON.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Peter Crawford <Peter@CRAWFORDSOFTWARE.DEMON.CO.UK>
Organization: Crawford Software Consultancy Limited
Subject: Re: writing selected records from large dataset to small...urgent!
KP <kpaddockNOkpSPAM@scohs.on.ca.invalid> writes
>I am having trouble with taking certain records from a larger
>dataset to a smaller one. The samples in the manual, etc. all
>describe ways to select 'the first 5 records' or 'the first and
>last' records or 'a random selection of records'.
>What I want to do is select a bunch of records such as: record
>12, record 3, record 342, record 16. I want to take these
>observations (by record i.d.) out of the big dataset and save
>them in a new, smaller one.
>I'm not sure whether to subset in a datastep with where, or to
>use proc print or proc printto. Below is one of my attempts with
>the error message:
>1 **********first make a much smaller complete database for
>the quarter w/just pall**;
>3 libname consults 'l:\research\kathie\consults';
>NOTE: Libref CONSULTS was successfully assigned as follows:
> Engine: V612
> Physical Name: l:\research\kathie\consults
>5 data consults.pall12;
>6 set consults.qscoh12 (where=(a6a in (43934,
>ERROR: Where clause operator requires compatible variables.
>any help is VERY much appreciated! I am in a deadline situation,
>so I'll be glad to receive quick replies!
If this selection process may be performed more than once, then it may
justify building the index (even better if it already exists )
Make an index on the variable A6A
make a picking list, then "go fishing with the index"
** building the index if it does not already exist;
proc datasets library= consults nolist;
modify qscoh12 ;
index create A6A;
/* if you don't know how long variable A6A is, then>>
proc sql noprint;
select length into :keylen from dictionary.columns
where libname = 'CONSULTS' and
memname = 'QSCOH12' AND
NAME = 'A6A' ;
*** now making that extract should be much faster with the index;
length a6a $&keylen ;
*length a6a $N if you know the N length ;
input a6a @@;
set consults.qscoh12 key = a6a ;
<picking list = the ID numbers/text you wanted, separated by blanks >
You may want to take care of situations where you seek an A6A which does
not exist...... look up online help on set with the KEY= option...