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 (August 2004, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 14 Aug 2004 16:14:35 -0400
Reply-To:     "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Subject:      Re: copying part of a SAS dataset

Haigang Zhou wrote: > I have a SAS dataset which contains stock trading data. The 3 columns > are stock ID, trading month and close price. The dataset looks like > > ID Month Price snip > I want to read the trading data of certain stocks to create a subset. > I have a file that contains the list of the stock IDs to be included > in the new subset. For example, the file is called stkid.txt, and has > 100 IDs. Is it possible that I can read the list into SAS and then > use the list to copy the trading data related to the stock IDs in the > list to a new dataset?

Very easy.

data studyids; infile 'stkid.txt'; input id; run;

proc sql; create table study as select * from tradingdata where id in (select id from studyids) ; quit;

There are about 19 other ways to select matching records between 'little' data and 'big' data.

-- Richard A. DeVenezia Done being productive? Try SAS Tetris. http://www.devenezia.com/downloads/sas/af?topic=27


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