|
|||
|
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 |
|
|
||||
|
||||
|
|
|
|||
|
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/ |
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Re: OT: Chance to Make SAS-L History: Did You Know That... | Craig Stroup | Newsgroup comp.soft-sys.sas | 0 | 08-14-2007 08:05 PM |
| Re: a quicker way to create macro variables | data _null_; | Newsgroup comp.soft-sys.sas | 0 | 06-06-2007 04:34 PM |
| proc report sas to excel: break not working | Bob Sayre | Newsgroup comp.soft-sys.sas | 1 | 06-29-2006 04:50 PM |
| Re: Read/Write Microsoft Word document | William W. Viergever | Newsgroup comp.soft-sys.sas | 0 | 05-31-2006 08:46 PM |
| Re: Read/Write Microsoft Word document | Joe Whitehurst | Newsgroup comp.soft-sys.sas | 0 | 05-31-2006 08:35 PM |