Date: Wed, 26 Oct 2005 20:56:00 -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: How to call another program within a program in SAS???
oseithedude@gmail.com wrote:
> Hey, I have a SAS program that, among other things, creates a dataset
> containing "bad" observations that I have no use for. There are about
> 2,000 of these "bad" observations in the data set but there may be
> 10-15 "good" observations that I want to keep in the dataset. There is
> a variable in the data set called "line" and each observation has a
> different "line" number. I have 2,000 "line" numbers that I have
> thrown into a if... not in statement that can delete all of the 2000
> "bad" observations as follows:
>
> data program;
> set original;
> if line not in ('1','456','767',etc..[2,000 numbers within this
> statement].);
> run;
>
> I don't want to put the program above within the "main" program that
> created the original dataset (because I don't want all 2,000 numbers
> within that main program), but I do want to be able to call the
> program above from the main program and have the original dataset be
> returned minus the 2,000 observations with "bad" line numbers. Is it
> possible to call another program within a program
> like this??? Thanks in advance...
Julie:
One very manageable scheme for the long run is to maintain the list of bad
line numbers in a separate table. A simple join or SQL statement can filter
the bad line numbers from any table having line numbers
data permdata.badlines;
input line;
cards;
1
456
767
run;
data mydata;
infile 'whereever';
input line and a whole lot more;
run;
proc sql;
delete from mydata where line in (select line from permdata.badlines);
quit;
--- a different tactic is too have a flag variable in mydata, and use a
where clause to exclude the bad lines when ever you process the data.
data mydata;
infile 'whatever';
input line and a whole lot more;
isbad = 0;
run;
proc sql;
update mydata set isbad = 1 where line in (select line from
permdata.badlines);
quit;
proc means data=mydata ....
where not isbad;
run;
--
Richard A. DeVenezia
http://www.devenezia.com/