|Date: ||Sun, 25 Aug 2002 10:51:40 -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>|
|Organization: ||MindSpring Enterprises|
|Subject: ||Re: Is there any way to drop variables from a SAS dataset when
all obs are missing?|
You will need to two-pass the data.
If there are no missing data in your data, you could read the first line to
determine how many fields need to be read in for a given file.
If the first line (or any line) can having missing data, you will need to
post process the data to drop your unwanted columns. There have been many
previous threads on how to drop columns containing only missing values.
Richard A. DeVenezia
"Know Spam" <NoSpam@nomail.com> wrote in message
> Hi, some help if you can!
> I'm going to read from several hundred flat files, some will have only
> 4 fields, some will have up to 125 fields. Because I don't have a way
> to know how many fields in advance to read, I'm setting the input
> statement to 125 possible using input x1-x125.
> This is a clumsy way to do it. Of course SAS will ignore variables in
> an analysis with all missing observations, but it can be messy in the
> In the example below, say that there are only 13 fields with data, so
> I want this dataset to have only x1 to x13.
> File test002 may have 78 fields, so there will be x1-x78 in the
> dataset that are all non-missing, x79 to 125 will be dropped.
> Is there a good way to do this? In my dreams, there's a SAS data
> option such as: data one(if var=all missing, then drop);
> options macrogen mprint mlogic ;
> %macro stats(file) ;
> data one ;
> infile "D:\data\&file" missover pad ;
> input var1-var125 ;
> file = "&file" ;
> %mend stats;