LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 1996, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Sun, 14 Apr 1996 02:53:58 GMT
Reply-To:   Floyd Lunt <72234.2357@COMPUSERVE.COM>
Sender:   "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:   Floyd Lunt <72234.2357@COMPUSERVE.COM>
Organization:   CompuServe Incorporated
Subject:   Re: Subsetting SAS Dataset with SCL Lists

Chris Roper <ROPER%VTVM1.BITNET@VTBIT.CC.VT.EDU> wrote:

>Dear SASL-ers,

>I've been scratching my head on this one and I am sure someone out there has >faced a similar problem, and I'm hoping they would share their solution. >The problem: SAS 6.11, FRAME application, >I've got an SCL list of names, which can vary in size, that I want to use to >subset a SAS dataset, such that if the SCL list contains the names 'CHARLIE' >'BOB' and 'LISA', I want to retrieve the observations from the SAS dataset >which contain those names. >I've tried using SCL arrays, and haven't had much luck, especially since SCL >doesn't support implicit arrays(remember the list length varies and I don't >know ahead of time how large the list will be).

You can use the listlen function to determine the number of items in the list and then use one of the getitem functions inside a do loop to build a where clause to subset the dataset. The list in the following code was created from datalistc so the count is already a named item in the list but you should be able to modify this to meet your need.

cnt=getnitemn(prplid,'COUNT');

if cnt>0 then do;

do j=1 to 5;

whcl{j}=' ';

end;

j=1;

whcl1=alias1||".uniquecd in ('";

do i=1 to cnt;

if length(whcl{j})>186 then j=j+1;

if i=1 then whcl1=trim(whcl1)||getnitemc(prplid,'UNIQUECD',i);

else whcl{j}=trim(whcl{j})||"', '"||getnitemc(prplid,'UNIQUECD',i);

end;

whcl{j}=trim(whcl{j})||"')";

end;

Hope this helps.


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